Hi,
In my form a user needs to agree or disagree (Yes/No) and based on that answer the user is redirected to a another form.
I use Custom Code:
In Redirect URL:
Redirect User I leave empty.
After submitting the form I get the error: Form name can NOT be empty!
It seems that the param $formname form the Custom Code is not being transferred to the Redirect URL. Any suggestions?
Robin
In my form a user needs to agree or disagree (Yes/No) and based on that answer the user is redirected to a another form.
I use Custom Code:
if ($_POST['Yes']) {
$formname = 'ABC';
}
if ($_POST['No']) {
$formname = 'DEF';
}
In Redirect URL:
Target URL: index.php?option=com_chronoforms
Params: chronoform={$formname}
Redirect User I leave empty.
After submitting the form I get the error: Form name can NOT be empty!
It seems that the param $formname form the Custom Code is not being transferred to the Redirect URL. Any suggestions?
Robin
Hi Robin,
There are several things that need fixing here:
How are you setting the Yes/No question in the form? Is it with Radio buttons? Or do you really have two inputs nmed Yes and No? I'll assume that is radion buttons named 'yes_no'
The ReDirect URL action:[list]reads values from the $form->data array; so you need to add your 'formname' to this array.
doesn't read curly brackets (it only accepts names from the $form->data array)
needs all of the options in the ParamsFields box (and not in the Target URL) [/list]
Putting all of these together change your Custom Code to
and in the ReDirect URL action the Target URL is 'index.php' and the Params Fields box
Bob
There are several things that need fixing here:
How are you setting the Yes/No question in the form? Is it with Radio buttons? Or do you really have two inputs nmed Yes and No? I'll assume that is radion buttons named 'yes_no'
The ReDirect URL action:[list]
Putting all of these together change your Custom Code to
<?php
if ( $form->data['yes_no'] == 'Yes' ) {
$form->data['formname'] = 'ABC';
} else {
if ($_POST['No']) {
$form->data['formname'] = 'DEF';
}
$form->data['set_option'] = 'com_chronoforms';
?>
and in the ReDirect URL action the Target URL is 'index.php' and the Params Fields box
option=set_option
chronoform=formname
Bob
Hi Bob,
The Yes & No are both submit buttons with the names 'Yes' and 'No'. Therefore I use
In Custom Code I now have:
Maybe I need to change this in: (?)
I use the params as you suggested. The Redirect Url will be :
index.php?option=set_option&chronoform=formname
It seems that both params ($form->data['formname'] and $form->data['set_option']) are not set in the custom code. This is strange even while the param $form->data['set_option'] is not in the IF-loop.
Robin
The Yes & No are both submit buttons with the names 'Yes' and 'No'. Therefore I use
If 'Yes' button is clicked:
if ($_POST['Yes'] )
If 'No'button is clicked:
if ($_POST['No'] )
In Custom Code I now have:
<?php
if ( $_POST['Yes']) {
$form->data['formname'] = 'ABC';
}
if ($_POST['No']) {
$form->data['formname'] = 'DEF';
}
$form->data['set_option'] = 'com_chronoforms';
?>
Maybe I need to change this in: (?)
<?php
if ($form->data['Yes']) {
$form->data['formname'] = 'ABC';
} else {
if ($form->data['No']) {
$form->data['formname'] = 'DEF';}
}
$form->data['set_option'] = 'com_chronoforms';
?>
I use the params as you suggested. The Redirect Url will be :
index.php?option=set_option&chronoform=formname
It seems that both params ($form->data['formname'] and $form->data['set_option']) are not set in the custom code. This is strange even while the param $form->data['set_option'] is not in the IF-loop.
Robin
Hi Bob,
I've used the Debugger after the Custom code and this replies with:
This means that the params are being set in the Custom Code but they are not being read in the Redirect URL.
Should I use Curl instead?
Robin
I've used the Debugger after the Custom code and this replies with:
Array
(
.....
[Yes] => Ik wil graag verder
[formname] => ABC
[set_option] => com_chronoforms
)
redirect_url
redirect_url_target_url: index.php
Redirect URL: index.php?option=set_option&chronoform=formname
This means that the params are being set in the Custom Code but they are not being read in the Redirect URL.
Should I use Curl instead?
Robin
Hi Robin,
I'm lost between the various versions here. Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Use cURL if you want to send the data but keep the user on your form page; if you want to redirect the user then the ReDirect URL and ReDirect user is the right set of options.
Bob
I'm lost between the various versions here. Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Use cURL if you want to send the data but keep the user on your form page; if you want to redirect the user then the ReDirect URL and ReDirect user is the right set of options.
Bob
Hi Bob,
Thanks for taking a closer look. I'll send you the zipped form by PM.
Robin
Thanks for taking a closer look. I'll send you the zipped form by PM.
Robin
Hi Bob,
I've found the solution so you don't need to figure out my form :-)
The solution is to change the params in the Redirect URL to:
Now it works!
Thanks again.
Robin
I've found the solution so you don't need to figure out my form :-)
The solution is to change the params in the Redirect URL to:
option={set_option}
chronoform={formname}
Now it works!
Thanks again.
Robin
This topic is locked and no more replies can be posted.