Checkbox element "if it is checkbox Send email"

Good Morning,
I need an idea or help, to do something complex for me ...
I present the case:
in a form, I have a "checked" option
if "checked" is checked
then send an email with "SUBJECT" and "BODY" saying "modified document" (it could be an email address stored in some table) for example.

it occurred to me ... to investigate by javascript or validations
I hope I can continue moving forward and listen to proposals
thanks
 
Good Morning,
after many attempts and trying different code ... I can't get the condition to evaluate correctly ...

I have tried with "raw" and without "raw"
I have also tried with the value of the chekbox which is "distribuir" and with value "1"
the table is correct "documentation_del_sistem"
and the checbox element is named "doc_distribuir" with the value "distribuir"

CODE:
if ('{documentation_del_sistem___doc_distribuir_raw}' == 1)
{
return true;
}


I'm doing something wrong ...
I hope to keep moving forward
Thanks for answering so quickly and for your attention ...
I observe that I have some programming limitations ...
PD.: JPG attached ... in case it can help
 

Attachments

  • checkboxFabrik  plugin.jpg
    checkboxFabrik plugin.jpg
    45.7 KB · Views: 71
There are a lot of threads in this forum on this matter. This element might contain several values (several box checked). It's actually a json encoded array.
You can add some debug in your validation eval like
Code:
var_dump('{documentation_del_sistem___doc_distribuir_raw}');
exit;
So you'll see the structure of the element.
You have to transform the value from json to array:
Code:
$checkbox = json_decode('{documentation_del_sistem___doc_distribuir_raw}');
then you'll get an array in which you have to find your value.
If there is only one checkbox this code may work :
Code:
$checkbox = json_decode('{documentation_del_sistem___doc_distribuir_raw}');
$checkbox = is_array($checkbox) ? $checkbox[0] : $checkbox;
return $checkbox == 1;
As far as the value of your unique checkbox is "1".
or even simpler
Code:
return strpos('{documentation_del_sistem___doc_distribuir_raw}', '1') !== false;
 
There are a lot of threads in this forum on this matter. This element might contain several values (several box checked). It's actually a json encoded array.
You can add some debug in your validation eval like
Code:
var_dump('{documentation_del_sistem___doc_distribuir_raw}');
exit;
So you'll see the structure of the element.
You have to transform the value from json to array:
Code:
$checkbox = json_decode('{documentation_del_sistem___doc_distribuir_raw}');
then you'll get an array in which you have to find your value.
If there is only one checkbox this code may work :
Code:
$checkbox = json_decode('{documentation_del_sistem___doc_distribuir_raw}');
$checkbox = is_array($checkbox) ? $checkbox[0] : $checkbox;
return $checkbox == 1;
As far as the value of your unique checkbox is "1".
or even simpler
Code:
return strpos('{documentation_del_sistem___doc_distribuir_raw}', '1') !== false;
good,
thanks for your reply
there is no simpler way ??

the table is called "documentacin_del_sistem"
and the element "checkbox" is called doc_distribucion

I present the case.
in a form ... if I check the checkbox
then
send a notification email
if the checkbox is not checked
then do not send notification email.

I have tried in several ways ... and at the moment, I can't ...

thanks for giving me ideas ...
 

Attachments

  • checkboxFabrik  pluginv3.jpg
    checkboxFabrik pluginv3.jpg
    51 KB · Views: 77
there is no simpler way ??
If you want to use php hooks you must learn how to do it.
@lcollong gave you not only the way to find out (for now and for future cases) but even a simple solution. So what do you expect with "simpler"?
 
If you want to use php hooks you must learn how to do it.
@lcollong gave you not only the way to find out (for now and for future cases) but even a simple solution. So what do you expect with "simpler"?
Apparently, I am quite limited with programming (it costs me a lot) ...
however I am going to study carefully @lcollong's proposal I have all Sunday to solve it ... thanks again.
thanks @ lcollong + @troester !!!
 
In your case it may be possible to use the "Email sent field" option.
http://fabrikar.com/forums/index.php?wiki/email-form-plugin/#options

Your "distribuir" must not be a checkbox but a radio element which is 0 if the email should be sent.
Email Sent Field - Optionally select an element which will be set to 1 when an email is sent. This also adds an implicit condition on sending, so no email will be sent if this element has a non-zero value. Can be a hidden field, or something like a YesNo radio button.
 
In your case it may be possible to use the "Email sent field" option.
http://fabrikar.com/forums/index.php?wiki/email-form-plugin/#options

Your "distribuir" must not be a checkbox but a radio element which is 0 if the email should be sent.
good morning,
I have changed the checkbox for radio button and it works fine for me.
I understand that data with checkbox and radio button is used differently ...
for now I will stick with the radio button option ... although I will try to understand and learn the process with the checkbox element.
I attach an image of what has been done, in case someone can help you.

Now I will look to investigate, if the email, I can send it to the group of users that I have selected in the form ... sometimes, it can be to a group ... and other times, it can be to another group ... for example ("human resources", "accounting" ... etc etc ...)
Thank you very much for helping me to see it more clearly !!!:):):)
 

Attachments

  • radiobuttonemail.jpg
    radiobuttonemail.jpg
    50.5 KB · Views: 73
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top