Forums

radio checkbox and events

thezak 17 Apr, 2014
Hi, i made a simple checkbox for user registration on joomla:

0=No
1=Yes
2=Maybe
3=I don't know..

now I want that if the user selects "no" or "maybe" or "i don't know.." the registration fails when press "submit" button (with appropriate warning), and if user select "yes" the recording/registrer user on joomla can continue.

how i can do this?
thank you,
thezak
GreyHead 17 Apr, 2014
Hi thezak,

That sounds like custom Serverside validation would do that OK.

Bob
thezak 17 Apr, 2014
hi GreyHead,
you mean "custom code" (in basic tab) or "server validation" (in validation tab) ?
In any case I am not a programmer and do not know what to write .. can you tell me the right way to compile the code? or some site that has an example of programming similar to mine?
i need like this:
http://www.w3resource.com/php/form/php-form-validation.php
(terms and conditions)
but i have 4 check input.. and i can't integrate correctly wath i see on this example, variables are a mystery to me...
Thank you,
thezak
Max_admin 17 Apr, 2014
Hi,

In v5 the "custom server validation" is the "event switcher", you will need to add one action at the top of the "on submit" event and paste a code like this:

<?php
if($form->data["radio_name"] == "yes"){
return "success";
}else{
return "fail";
}

And then add a "show stopper" action inside the "on fail" event of the "event switcher".

FAQ:
http://www.chronoengine.com/faqs/70-cfv5/5212-event-switcher.html
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
thezak 18 Apr, 2014
Hi Mr. Admin,
I added your code and follow the step by step procedure, but does not seem to work. what happens is that the recording is done the same and do not see the page generated by "display message".
thank you,
thezak
Max_admin 18 Apr, 2014
Did you update the radio name in the line below to your radio field name ?
if($form->data["radio_name"] == "yes"){


Please also post a screenshot for your current events setup!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
thezak 20 Apr, 2014
hi,
i set radio button like this image:
http://s13.imagestime.com/out.php/i942040_radio13.jpg

here you can see my radio button: http://s13.imagestime.com/out.php/i942046_radio132.jpg

and this is my setup:
http://s13.imagestime.com/out.php/i942047_radio133.jpg

I would make sure that if the user press "yes", the form must be completed (if other parameters are corrects of course), but any other choice leads to a warning of any kind.

i see that radio button have tab "dynamic data" and "event".. not possible to use this tab in some way for my problem ?

thank you very much.
thezak
Max_admin 22 Apr, 2014
Hi thezak,

Your current setup would display a blank page if the choice is not "yes", otherwise the form setup will be completed as normal, what would you like to change in the current setup ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
thezak 23 Apr, 2014
Hi Max,
I would like to appear a warning that explains the inability to continue with registration because the choice is wrong.
As when I enter a user name already in use, the page is reloaded and I get the warning at the top, something like this in practice. That's possible?

thankyou,
thezak
Max_admin 23 Apr, 2014
Just add "Display message" action ABOVE the "show stopper", and write any message you need there!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
thezak 24 Apr, 2014
Everything is perfect Max!,
but I need another small step to finish my form.
I added two radiobox on my form, both must have a clear choice to be able to continue ("yes").
so I tried to insert like this in "event switcher":

<?php
if($form->data["radio_name[b]11[/b]"] == "yes"){
return "success";
}else{
return "fail";
}
<?php
if($form->data["radio_name[b]22[/b]"] == "yes"){
return "success";
}else{
return "fail";
}


and on "display message" i write about radio_name11 and radio_name22 in case of warning.
but does not seem to work

so i try to add another "event switcher" including only "radio_name22":

<?php
if($form->data["radio_name[b]22[/b]"] == "yes"){
return "success";
}else{
return "fail";
}


(in pratice i clone my first "event swithcer" and change radio_name)
but even in this case it does not work

How i can proceed ?
thank you for you patience.

thezak.
GreyHead 24 Apr, 2014
Hi thezak,

There's a problem with the <?php tags, and the logic in your first example. Please try this:
<?php
if ( $form->data['radio_name11'] == "yes" || $form->data['radio_name22'] == "yes" ) {
  return "success";
} else {
  return "fail";
}
?>

Bob
thezak 28 Apr, 2014
<?php
Hi,
i publish at this page the form:
http://bruttidibrutto.altervista.org/index.php?option=com_chronoforms5&chronoform=Registrazione_al_sito

i modify like this:
(of course in "design" tab a give appropriate name to fields)

if ( $form->data['maggiorenne'] == "si" || $form->data['termini'] == "si" ) {
  return "success";
} else {
  return "fail";
}
?>



I have tried many times, clicking "si" (=yes) in the first radio and "no" in the second, and vice-versa.. also i set "si" to all (at this point registration must success) .. then the result is always the error page (my display message) and the user is not logged (not receiving any mail and will not be recorded in joomla)
note: if i delete radio, user register in joomla correctly.

I don't understand where i'm wrong.

thank you
thezak.
GreyHead 28 Apr, 2014
Hi theezak,

It looks as though the values of maggiorenne are 0, 1, 2, or 3 so it can never be 'si'

Bob
thezak 28 Apr, 2014
Hi Bob,
i understand that, but i made like this :

if ( $form->data['maggiorenne'] == "1" || $form->data['termini'] == "1" ) {
  return "success";
} else {
  return "fail";
}
?>


the registration done when i wrong just one radio (es: maggiorenne=yes and termini=no or vice-versa)
but i need registration fail when i wrong just one of 2, and success only if the response of the two radio is "si" (value 1)
seems that enough just one of them is successful

I do not know if I need to change the php code you have given me, or if there is an error in some other part of the form outside of the radio

thank you
thezak
GreyHead 28 Apr, 2014
Answer
Hi thezak,

If you want both to be == 1 then change the OR || for AND &&

Bob
thezak 29 Apr, 2014
Perfect! now the module works in an "interesting way", as Spock would say, second in command of the Enterprise!

thank you very much for your support!
GreyHead 29 Apr, 2014
HI thezak,

The values of radio13 are 0, 1, 2 not 'no', 'yes', . . . so the code needs to be
if($form->data["radio_name"] == "1"){

Bob
This topic is locked and no more replies can be posted.