1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 211 Views |
-
Retrieving data out of Check Boxes - Groups

15 February 2012 at 11:54am Last edited: 15 February 2012 11:57am
Hi
I have created a form using the form module. This contains a Checkbox group I am now trying to extract the values from each of the check boxes in that group. Can anyone point me in the direction of a tutorial or example or explain how I could do this?
For information, I am doing this in the forms controller class, within the process function. I normally get the values out of fields by doing the following:
function process($data, $form) {
$this->weekType = $data["EditableDropdown42"];
// Run through form to get the job type
foreach ($this->Fields() as $field) {
switch ($field->Name) {
case "EditableDropdown3":
$this->runJob($data[$field->Name]);
break;
}
}Can anyone help please?
Thanks in advance, Sean
-
Re: Retrieving data out of Check Boxes - Groups

16 February 2012 at 1:25am Last edited: 16 February 2012 1:26am
Do a var_dump($data); or a
foreach($data as $key => $value) echo"$key - $value<br />";
to see what gets posted -
Re: Retrieving data out of Check Boxes - Groups

16 February 2012 at 5:21am Last edited: 16 February 2012 5:23am
Nearly got it? The dump returns the following :
.....
'EditableCheckboxGroupField14' =>
array
'aaa' => string 'aaa' (length=3)
'ccc' => string 'ccc' (length=3)
.....where both aaa and ccc are the names of each tick box (that are ticked). However the foreach does not execute so I can't tell whats in the array:
foreach ($data[$field->Name] as $key => $value) {
echo"$key - $value<br />";
}
The code does not even get into this loop.Any help most appreciated.
| 211 Views | ||
|
Page:
1
|
Go to Top |
