-
-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
Hi,
first thank you for this tool as this makes working with forms much simpler for me!
In my project I have a list of days that can be selected via checkboxes
$form->checkbox('days[]', 'first day', 'day1', 'day1');
$form->checkbox('days[]', 'second day', 'day2', 'day2');
$form->checkbox('days[]', 'third day', 'day3', 'day3');
similar on how this is approached in this tutorial video (https://www.youtube.com/watch?v=-nbE4qkMxis&ab_channel=TimGavin)
when it comes to validation I try to grab the values as follows:
$days = $form->post('days');
This is similar to how the checkboxes in the video tutorial are validated, however I get an uncaught exception
Fatal error: Uncaught TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, array given in C:\xampp\htdocs\prereg\Formr\class.formr.php:1824 Stack trace: #0 C:\xampp\htdocs\prereg\Formr\class.formr.php(1824): htmlspecialchars(Array, 3, 'UTF-8') #1 C:\xampp\htdocs\prereg\Formr\class.formr.php(1731): Formr\Formr->_post('days', '', '') #2 C:\xampp\htdocs\prereg\index.php(24): Formr\Formr->post('days') #3 {main} thrown in C:\xampp\htdocs\prereg\Formr\class.formr.php on line 1824
I guess something changed in the handling of checkbox arrays in the past 10 years since the video was uploaded, but sadly I can not find good resources on how to do this instead, any pointers?
Metadata
Metadata
Assignees
Labels
No labels