Reputation: 10812
I am using select
. I want to ensure that in CakePHP3 FormHelper, I always have the key inside request->data regardless if it is empty.
Currently, my code is
<?= $this->Form->select('rooms[]', $rooms, ['id' => 'room-tags', 'multiple', 'empty' => '']); ?>
I have tried hiddenField
. It does not work.
I need to ensure that inside request->data I will always have the key rooms
which points to an empty array.
Upvotes: 0
Views: 68
Reputation: 60453
You are defining the multiple
option wrong, while passing it as a value makes it into the HTML element as an attribute, the form helper will not be recognize it as an option.
This is how you have to define it in order to for it to act as a option.
'multiple' => true
Upvotes: 1