Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Retrieving data out of Check Boxes - Groups

Go to End

3 Posts   698 Views


Community Member, 8 Posts

15 February 2012 at 11:54am

Edited: 15/02/2012 11:57am


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":

Can anyone help please?

Thanks in advance, Sean


Forum Moderator, 1391 Posts

16 February 2012 at 1:25am

Edited: 16/02/2012 1:26am

Do a var_dump($data); or a

foreach($data as $key => $value) echo"$key - $value<br />"; 

to see what gets posted


Community Member, 8 Posts

16 February 2012 at 5:21am

Edited: 16/02/2012 5:23am

Nearly got it? The dump returns the following :

  'EditableCheckboxGroupField14' => 
      '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.