Hi everyone,
we have the following problem in one of our forms. The form consists of three checkbox groups, where the first has a label "offers" and id "offers[]", while the others have no labels and ids "offers1[]" and "offers2[]". In our "On Submit" event, we have a "Handle Arrays" and an "Event Loop", which calls the "on load" event again.
Now, for a text field and a drop down field, this procedure keeps the set values when the event loop is invoked. But the marks in the check box groups disappear. How can we fix this?
Thanks for the help,
best, Skrodde
we have the following problem in one of our forms. The form consists of three checkbox groups, where the first has a label "offers" and id "offers[]", while the others have no labels and ids "offers1[]" and "offers2[]". In our "On Submit" event, we have a "Handle Arrays" and an "Event Loop", which calls the "on load" event again.
Now, for a text field and a drop down field, this procedure keeps the set values when the event loop is invoked. But the marks in the check box groups disappear. How can we fix this?
Thanks for the help,
best, Skrodde
Hi Skrodde,
What is the Event Loop doing?
If you can put the Event Loop before the Handle Arrays action then the checkbox values will be loaded correctly.
If not then you have to reverse the Handle Arrays action in the On Load event by adding a Custom Code action before the HTML (Render form) action with code like this:
Bob
What is the Event Loop doing?
If you can put the Event Loop before the Handle Arrays action then the checkbox values will be loaded correctly.
If not then you have to reverse the Handle Arrays action in the On Load event by adding a Custom Code action before the HTML (Render form) action with code like this:
<?php
$offers_array = array(
'offers',
'offers1',
'offers2'
);
foreach ($offers_array as $o ) {
if ( !empty($form->data[$o]) ) {
$form->data[$o] = explode(',', $form->data[$o]);
}
}
?>
Bob
Hi Bob,
thanks for the fast reply. As to your question and suggestion:
The event loop simply calls "load", so I hope, it invokes the "On Load" event.
This indeed helped, sort of. Now the checkmarks are correctly placed when I submit the form (i.e. reload it). However, they are not processed. Probably, we access them incorrectly. How would I check the state of a checkbox in a checkboxgroup with the "On Load" event? I tried
but it only gives me "Array", independent of the state of the checkboxes in the group "offers". So how I can see whether the checkboxes in "offers" (and in "offers1", "offers2") are checked or not by the user?
Best, Skrodde
thanks for the fast reply. As to your question and suggestion:
What is the Event Loop doing?
The event loop simply calls "load", so I hope, it invokes the "On Load" event.
If you can put the Event Loop before the Handle Arrays action then the checkbox values will be loaded correctly.
This indeed helped, sort of. Now the checkmarks are correctly placed when I submit the form (i.e. reload it). However, they are not processed. Probably, we access them incorrectly. How would I check the state of a checkbox in a checkboxgroup with the "On Load" event? I tried
echo $form->data['offers'];
but it only gives me "Array", independent of the state of the checkboxes in the group "offers". So how I can see whether the checkboxes in "offers" (and in "offers1", "offers2") are checked or not by the user?
Best, Skrodde
Allright, I think I got it. I experimented a little more, deleting the "Handle Arrays" action and doing it all via Custom Code. My setup no consists of
where the string $offers can then be searched for the values of the checkboxes. I do have a subsequent question, which I will poste in a different thread.
Thanks for the help here.
Best, Skrodde
$form->data['offers'] = implode(",", $form->data['offers']);
$form->data['offers1'] = implode(",", $form->data['offers1']);
$form->data['offers2'] = implode(",", $form->data['offers2']);
$offers=$form->data['offers'] . $form->data['offers1'] . $form->data['offers'];
where the string $offers can then be searched for the values of the checkboxes. I do have a subsequent question, which I will poste in a different thread.
Thanks for the help here.
Best, Skrodde
This topic is locked and no more replies can be posted.