Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Added id field by default to AbstractFieldset and AbstractFieldsetInp…
Browse files Browse the repository at this point in the history
…utFilter.
  • Loading branch information
rkeet committed Nov 29, 2018
1 parent 4f01c99 commit 425e7f4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Fieldset/AbstractFieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Keet\Form\Fieldset;

use Zend\Form\Element\Hidden;
use Zend\Form\Fieldset;
use Zend\I18n\Translator\TranslatorAwareTrait;
use Zend\InputFilter\InputFilterAwareTrait;
Expand All @@ -10,4 +11,18 @@ abstract class AbstractFieldset extends Fieldset
{
use InputFilterAwareTrait;
use TranslatorAwareTrait;

/**
* {@inheritdoc}
*/
public function init()
{
$this->add(
[
'name' => 'id',
'type' => Hidden::class,
'required' => false,
]
);
}
}
21 changes: 21 additions & 0 deletions src/InputFilter/AbstractFieldsetInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

namespace Keet\Form\InputFilter;

use Zend\Filter\ToInt;
use Zend\I18n\Validator\IsInt;

abstract class AbstractFieldsetInputFilter extends AbstractInputFilter
{
/**
* {@inheritdoc}
*/
public function init()
{
$this->add(
[
'name' => 'id',
'required' => false,
'filters' => [
['name' => ToInt::class],
],
'validators' => [
['name' => IsInt::class],
],
]
);
}
}

0 comments on commit 425e7f4

Please sign in to comment.