Hello.
I have been trying to read and write values to checkbox group elements in vain.
Please post here a functional code snippet that would select/deselect a checkbox called "beta" in a checkbox group called "alpha"
Thanks
I have been trying to read and write values to checkbox group elements in vain.
Please post here a functional code snippet that would select/deselect a checkbox called "beta" in a checkbox group called "alpha"
Thanks
Hi Lesanjo,
Sorry, I don't understand your question. Please explain with more details and perhaps an example.
Bob
Sorry, I don't understand your question. Please explain with more details and perhaps an example.
Bob
I want to detect which checkboxes in a group have been selected. I tried something like the following:
but I get;
<?PHP
echo $form->data[alpha][beta];
?>
but I get;
* Uninitialized string offset
Hi Lesanjo,
If you temporarily add a debugger action you will see the full $form->data array.
For the values of the 'alpha' group try
You can't use 'beta' as a second key, it will be a value if it is selected.
Bob
If you temporarily add a debugger action you will see the full $form->data array.
For the values of the 'alpha' group try
<?php
echo $form->data['alpha'];
?>
You can't use 'beta' as a second key, it will be a value if it is selected.
Bob
Thanks for the help. I have come across the following solutions.
1. In order to make a selection programmatically, ensure the custom code is set to controller, not view. then its as simple as...
$form->data[alpha]='beta';
2. For more flexible manipulation of predefined group checkboxes, is better to use PHP in_array to test the group form array
in_array('beta',$array)
Thanks again.
1. In order to make a selection programmatically, ensure the custom code is set to controller, not view. then its as simple as...
$form->data[alpha]='beta';
2. For more flexible manipulation of predefined group checkboxes, is better to use PHP in_array to test the group form array
in_array('beta',$array)
Thanks again.
This topic is locked and no more replies can be posted.