Hello,
I think I have a quite simple problem.
In a form methode I create a form with a variable count of checkboxes.
$SkripteAll = DataObject::get('Skript');
$LastField = 'Nachname';
foreach($SkripteAll as $SkriptItem)
{
$fields->insertAfter(new CheckboxField($SkriptItem->Name, $SkriptItem->Name),$LastField);
$LastField = $SkriptItem->Name;
}
I the submit-method I want to save these information depending on the chosen checkboxes. For example I have 4 checkboxes and the user marked three of the four checkboxes I need to save three records.
But now I have the problem that I don't know in the submit-method how I can get the checkboxes with the value true. Because in this method I have to decide if the record has to be saved or not.
My first try is that
function doSubmit($data, $form) {
foreach ($form->fields as $FieldItem)
{
//Here I have to decide if the $FieldItem is a checkbox
//Furthermore I have to decide if the checkbox is true
}
}
Best regards, Beppo