Answer the question
In order to leave comments, you need to log in
How to make the \Zend\Form\Element\Select field optional?
I set the form element like this:
$select = array();
foreach ($cFields["contents"] as $variant) {
$select[$variant] = $variant;
}
$form->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => $field['name'],
'options' => array(
'label' => $field['title'],
'empty_option' => 'Выбрать из списка',
'value_options' => $select,
),
));
...
$form = $this->getProfileForm();
$form->setData($this->request->getPost());
$form->setInputFilter(new \Zend\InputFilter\InputFilter());
if ($form->isValid()) {
...
Answer the question
In order to leave comments, you need to log in
'required' => false
I'm only superficially familiar with the Zend Framework, but have you
tried adding values like 'allow_empty' => true
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question