Hi! Is it possible in ZF2 to set a checked values in multicheckbox?
I tried to do it using array notation, as well as setting the values
directly using the setValue (), but nothing helps.
My code (Form):
public function bind($object, $flags = Form::VALUES_NORMALIZED)
{
$this->add([
'name' => 'roles',
'type' => 'multicheckbox',
'options' => [
'label' => 'Applicable roles',
'label_attributes' => [
'class' => 'checkbox',
],
'value_options' => array_combine(
$object->getRoles(),
$object->getRoles()
),
],
'attributes' => [
'value' => $object->findApplicableRoles(),
],
]);
$spec = $this->getInputFilter();
$spec->add([
'name' => 'roles',
'required' => false,
]);
parent::bind($object, $flags);
return $this;
}
I checked, the "$object->getRoles()" returns array('guest', 'user', 'admin')
The "$object->findApplicableRoles()" returns array('guest', 'user')
But as a result of the form shows that all the check boxes are checked.
When I save the form, all the flags are set correctly. But when I go to
another page and then come back - again all checkboxes are checked :(
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-set-checked-value-in-Multicheckbox-tp4661501.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]