Forums

Get checkbox value in php

mayergreenberg259 15 Feb, 2024
I have a form that submits a checkbox. I would like to be able to test whether that checkbox is checked or not. I would like to do this in php upon submission of the form.

If I use $this->data('Checkbox_Name'), then I just get back the value of the checkbox, regardless of whether it is checked or not.

How can I tell whether it is checked?
Max_admin 21 Feb, 2024
Answer
The checkbox has a "ghost" value which can be configured to be different of the checkbox value itself, then you can check which value is there
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 23 Feb, 2024
in your checkbox settings > Behaviors > Data > Ghost field

you can set the value there

Also without doing that, enable the form debug and submit the form once withOUT checking the box, what value do you have in the data array under the checkbox name ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.