This should hopefully be a nice simple question.
On a form I have a number of checkboxes relating to selecting various users for a particular function. The checkbox is created like so
$this->Form->input("user_select", array(
"type" => "checkbox",
"name" => "data[Registration][User][]",
"id" => "UserId" . $user['User']['id'],
"value" => $user['User']['id'],
"label" => false
));
When this form is submitted it comes through to the registration controller but the request->data array contains the checkboxes that aren't selected too in the format:
array(
'Registration' => array(
'Users' => array(
(int) 0 => '0',
(int) 1 => '0',
(int) 2 => '0',
(int) 3 => '0',
(int) 4 => '31',
(int) 5 => '0',
(int) 6 => '11'
),
)
Now there's nothing wrong with the data, its clear to see that user's 31 and 11 have been selected but I'd much prefer an array of the form:
array(
'Registration' => array(
'Users' => array(
(int) 4 => '31',
(int) 6 => '11'
),
)
This would make processing and validation much much easier.
So, Does CakePHP have a facility to prevent unselected checkboxes being shown in the request->data array?