Skip to content

Commit

Permalink
add order number to category admin
Browse files Browse the repository at this point in the history
  • Loading branch information
rserry committed Oct 11, 2023
1 parent 0235964 commit 0c7724e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions module/PageBundle/Form/Admin/Category/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public function init()
)
);

$this->add(
array(
'type' => 'text',
'name' => 'order_number',
'label' => 'Ordering Number',
'options' => array(
'input' => array(
'filters' => array(
array('name' => 'StringTrim'),
),
'validators' => array(
array('name' => 'Int'),
),
),
),
)
);

$this->addSubmit('Add', 'category_add');
}

Expand Down
5 changes: 5 additions & 0 deletions module/PageBundle/Hydrator/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ protected function doHydrate(array $data, $object = null)
$object->setParent(null);
}

if ($data['order_number'] != '') {
$object->setOrderNumber($data['order_number']);
}

foreach ($this->getLanguages() as $language) {
$translation = $object->getTranslation($language, false);

Expand Down Expand Up @@ -71,6 +75,7 @@ protected function doExtract($object = null)
}

$data['parent'] = $object->getParent() ? $object->getParent()->getId() : '';
$data['order_number'] = $object->getOrderNumber() ?? '';

return $data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<tr>
<th>Name</th>
<th width="200px">Parent</th>
<th width="100px">Order Nr.</th>
<th width="70px">Action</th>
</tr>
</thead>
Expand All @@ -32,6 +33,7 @@
<tr class="item item-{{ page_category.getId() }}">
<td>{{ page_category.getName(language) }}</td>
<td>{{ page_category.getParent().getTitle(language) }}</td>
<td>{{ page_category.getOrderNumber() }}</td>
<td class="actions">
{% if hasAccess('page_admin_category', 'edit') %}
<a href="{{ url('page_admin_category', {"action": "edit", "id": page_category.getId()}) }}" class="edit">Edit</a>
Expand Down

0 comments on commit 0c7724e

Please sign in to comment.