в моем наборе полей:
Код: Выделить всё
class myFieldset extends Fieldset implements InputFilterProviderInterface
{
public function init()
{
// add form elements
}
public function getInputFilterSpecification()
{
$inputFilter['myFormElement'] = [
'required' => true,
'filters' => [[ ... ],],
'validators' => [[ ... ],],
'allow_empty' => false,
'continue_if_empty' => false,
];
// more filters
return $inputFilter;
}
}
Код: Выделить всё
class myForm extends Form
{
public function __construct()
{
// ...
// add elements from fieldset
$this->add([
'name' => 'myFieldset',
'type' => 'Application\Form\Fieldset\myFieldset',
'options' => [
'use_as_base_fieldset' => true,
],
]);
// add new element
$myFieldset = $this->get('myFieldset');
$myFieldset->add([
'name' => 'additionalElement',
'type' => 'Zend\Form\Element\ ... ',
'attributes' => [],
'options' => [],
]);
// update inputfilter
$input = new Input('additionalElement');
$input->setRequired(false);
$currentInputFilter = $this->getInputFilter();
$currentInputFilter->add($input);
$this->setInputFilter($currentInputFilter);
// submit buttons
}
}
Подробнее здесь: https://stackoverflow.com/questions/502 ... form-class
Мобильная версия