Page 1 of 1
Radio buttons won't return any value
Posted: Wed Nov 11, 2015 9:22 am
by chunteler
Hi,
I'm using CMSMS 1.12.
I'm busy developing a module for a customer.
I have created a form with PHP and Smarty.
The text input types submit values fine.
I can't get the radio buttons to return any value.
I've used {html_radios} from Smarty. I also tried CreateInputRadioGroup. Now I'm using simple HTML in my template.
Unfortunately, without any success so far.
Can anybody help me out?
Thanks in advance.
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 1:26 pm
by chunteler
Actually, I seem to have this issue not only with radio buttons, but also with checkboxes and dropdowns.
How can I get the value to be passed through and remembered?
Anybody?
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 1:42 pm
by Jo Morg
We need far more info about what you are trying to do than what you are providing...
Specifically, but not limited to:
- - is it a module action?
- - which methods from the CMSMS API are you using, if any?
- - are you sure the variables are being passed to Smarty?
- - a sample of the template containing the form (doesn't have to be an exact copy but needs to have the same code logic you are trying to use);
- - is the form being submitted to the same action (assuming you are using the CMSMS API);
- - is it a frontend or backend form?
- - etc...
chunteler wrote:I have created a form with PHP and Smarty.
The text input types submit values fine.
I can't get the radio buttons to return any value.
This is as vague as it can be... too many things can be wrong...
http://forum.cmsmadesimple.org/viewtopi ... =40&t=2661
If you don't provide more detailed information, chances are that your questions will keep being ignored...
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 1:53 pm
by chunteler
Thanks for your reply Jo Morg!
It is indeed a module action.
It is a front end form.
The form is submitted to the same action.
I'm pretty sure the variables are being sent to Smarty.
I'm including both .php en .tpl files with this reply.
Hope this makes it more clear.
Thanks.
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 2:11 pm
by Jo Morg
Given the way CMSMS API works with form submissions you always need to insert the action id value before the wanted field name otherwise the field will be ignored. While methods like
$this->CreateInput... do this for you from the $id var that is set in scope on the action file/method, you'll have to add it yourself when using Smarty tags such as
{html_options}.
So you'll need to replace:
Code: Select all
{html_options name=prijzen options=$PrijsOptions selected=$prijs_select}
whith:
Code: Select all
{html_options name="{$actionid}prijzen" options=$PrijsOptions selected=$prijs_select}
Additionally you'll have to adjust all the names associated with those smarty tags in the same way.
HTH
Note: As you can see it was easy to try to help given enough information...
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 2:45 pm
by chunteler
Great! Thanks Jo Morg!
How do I then call the value?
$prijzen = $params['?????']
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 2:51 pm
by Jo Morg
The parameters are sent to the action already stripped of the action id, so you are doing it correctly, in this case: $prijzen = $params['prijzen']; is correct, although you may have to check if the parameter is set before using it.
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 4:37 pm
by chunteler
I'm sorry, but I can't get it to work.
I'm new to CMSMS and Smarty.
I'm posting my new code. What am I missing?
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 4:57 pm
by Jo Morg
Try putting:
at the very top of the action file to see which parameters are available on that action and if they hold the values you are expecting.
Also keep in mind that the CMSMS module API may drop unknown parameters (if you have
$this->RestrictUnknownParams(); called on the constructor, on the deprecated
SetParameters method, or on
InitializeFrontend method).
If these are not registered for frontend actions with
SetParameterType method call it may not work. Check the admin log for errors regarding parameters.
Also consult the
API docs.
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 5:16 pm
by calguy1000
Also, be sure you read the module writing tutorial at:
http://docs.cmsmadesimple.org/uploads/M ... torial.pdf
BTW: All of those 'CreateInputHidden' and 'CreateInputText', etc, methods are deprecated and we discourage their use.
Re: Radio buttons won't return any value
Posted: Fri Nov 13, 2015 7:28 pm
by chunteler
Thanks both for your help.
One last question... My customer uses CMSMS 1.12.
The document you do reference to Calguy 1000 is for CMSMS 2.0.1+.
Will that work?