Critical Error when I indicated certain field IDs. The field IDs are not in order, a few larger numbers are at the top of the page.
This is the error that I received:
“There has been a critical error on this website.” https://bit.ly/3x8zb64
I discovered the error on this code.
<input type=“checkbox” <?php echo in_array("Letter from School/ Institution", $form_data['field'][49])?'checked="checked"':'' ?>>
However, removing just this code did not help. I have many similar codes below this one.
Here’s an example of same file but with input codes at the lower part of the page removed. https://bit.ly/3PzkeQP
If I just copied the codes that worked and paste them below, there’s no error. Error occurs only when I entered the Field Ids and upload the file.
Is there a limit to how many input codes I can use in a page? Or is there a different explanation?
Have you tried using debug mode and the ?data=1 query argument to check the contents of the $form_data to ensure the field you are trying to access is included?
Following your advice, I managed to isolate and identify the error.
Though none of my checkboxes are required fields, if no option is selected on any of the checkboxes, I get a fatal error. My form contains many checkboxes.
Is there a setting that would allow users to not pick an option on a checkbox?
When I pick at least one option on the checkboxes, no error appears.
Ideally, $form_data would always use an array for checkbox fields – even when empty. But for backwards compatibility reasons we can’t change this behaviour, and are locked into the use of an empty string when nothing is selected.