Forums

email text depending on checkbox

hekla 22 Aug, 2019
Hi

I would like to add text from a Read DB action to an email, which is sent when submitting the form only if the visitor has a certain checkbox checked.

How can I do that?
Can I add a submit action like if {data:checkboxA} = "yes" then return {var:read_data_submit.title.additional_info}

I couldn't figure it out …

Thank you
GreyHead 22 Aug, 2019
Hi Hekla,

Again, there are a couple of ways to do this: you can use a Switch action to set a variable value depending on another variable, or you can use a PHP action with Custom PHP to set the value - but note that in a PHP action you need to use the $this->data to get the variable values instead of the short codes.

Bob
hekla 23 Aug, 2019
Thanks Greyhead for your answer.

What I don't know – how do I get the result from the checkbox – checked or not?
GreyHead 23 Aug, 2019
Hi Hekla,

If the check-box is checked then it will have the corresponding value in the $form->data; if not there will be no entry BUT there is an option to set a default value which will be returned if it is not checked, it can be helpful to set that. Using a Debugger action temporarily will show you the values being returned.

Bob
healyhatman 26 Aug, 2019
If you UNCHECK the "ghost value" option, then if the box is not ticked it won't exist. If you tick the ghost box, then it will instead send the ghost value when not ticked.

So if you're not sending a ghost value you can use {data.empty:checkboxname} in your switch, and it will be 'true' if it is not checked. Otherwise you can do {data:checkboxname} and check for the ghost value you set.
Max_admin 26 Aug, 2019
1 Likes
You can use a "Data builder" inside "If Conditions" the if conditions will check the checkbox value is not empty, and the data builder will set a custom var to the value you need, then call it in the email with {var:your_var_name}

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.