Anonymous
Как настроить ObjectMultiCheckBox для сохранения пустого элемента?
Сообщение
Anonymous » 17 окт 2024, 11:01
У меня в форме есть следующий элемент, и я перепробовал все возможные варианты, найденные в Интернете, чтобы разрешить пустое значение для элемента:
Код: Выделить всё
$this->add(array(
'type' => 'DoctrineModule\Form\Element\ObjectMultiCheckbox',
'name' => 'directPractice',
'options' => array(
'label' => 'A. Check all direct practice field education assignments',
'label_attributes' => array(
'class' => 'label-multicheckbox-group'
),
'required' => false,
'allow_empty' => true,
'continue_if_empty' => false,
'object_manager' => $this->getObjectManager(),
'target_class' => 'OnlineFieldEvaluation\Entity\FieldEducationAssignments', //'YOUR ENTITY NAMESPACE'
'property' => 'directPractice', //'your db column name'
'disable_inarray_validator' => true,
'value_options' => array(
'1' => 'Adults',
'2' => 'Individuals',
'3' => 'Information and Referral',
'4' => 'Families',
array(
'value' => 'Other',
'label' => 'Other (specify)',
'label_attributes' => array(
'class' => 'bindto',
'data-bindit_id' => 'otherDirectPracticeTxt_ID'
),
'attributes' => array(
'id' => 'otherDirectPractice_ID',
),
)
),
),
'attributes' => array(
'value' => '1', //set checked to '1'
'multiple' => true,
)
));
Я всегда получаю одно и то же сообщение об ошибке, когда оно пусто:
Ошибка проверки «directPractice»:Array(
[isEmpty] => Значение обязательно и не может быть пустым
)
Подробнее здесь:
https://stackoverflow.com/questions/288 ... ty-element
1729152084
Anonymous
У меня в форме есть следующий элемент, и я перепробовал все возможные варианты, найденные в Интернете, чтобы разрешить пустое значение для элемента: [code] $this->add(array( 'type' => 'DoctrineModule\Form\Element\ObjectMultiCheckbox', 'name' => 'directPractice', 'options' => array( 'label' => 'A. Check all direct practice field education assignments', 'label_attributes' => array( 'class' => 'label-multicheckbox-group' ), 'required' => false, 'allow_empty' => true, 'continue_if_empty' => false, 'object_manager' => $this->getObjectManager(), 'target_class' => 'OnlineFieldEvaluation\Entity\FieldEducationAssignments', //'YOUR ENTITY NAMESPACE' 'property' => 'directPractice', //'your db column name' 'disable_inarray_validator' => true, 'value_options' => array( '1' => 'Adults', '2' => 'Individuals', '3' => 'Information and Referral', '4' => 'Families', array( 'value' => 'Other', 'label' => 'Other (specify)', 'label_attributes' => array( 'class' => 'bindto', 'data-bindit_id' => 'otherDirectPracticeTxt_ID' ), 'attributes' => array( 'id' => 'otherDirectPractice_ID', ), ) ), ), 'attributes' => array( 'value' => '1', //set checked to '1' 'multiple' => true, ) )); [/code] Я всегда получаю одно и то же сообщение об ошибке, когда оно пусто: Ошибка проверки «directPractice»:Array( [isEmpty] => Значение обязательно и не может быть пустым ) Подробнее здесь: [url]https://stackoverflow.com/questions/28869737/how-to-configure-objectmulticheckbox-to-persist-an-empty-element[/url]