Radio buttons won't return any value

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Radio buttons won't return any value

Post 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.
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Radio buttons won't return any value

Post 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?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Radio buttons won't return any value

Post 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...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Radio buttons won't return any value

Post 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.
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

[The extension txt has been deactivated and can no longer be displayed.]

User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Radio buttons won't return any value

Post 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...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Radio buttons won't return any value

Post by chunteler »

Great! Thanks Jo Morg!
How do I then call the value?
$prijzen = $params['?????']
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Radio buttons won't return any value

Post 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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Radio buttons won't return any value

Post 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?
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

[The extension txt has been deactivated and can no longer be displayed.]

User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Radio buttons won't return any value

Post by Jo Morg »

Try putting:

Code: Select all

debug_display($params);
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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Radio buttons won't return any value

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Radio buttons won't return any value

Post 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?
Locked

Return to “Developers Discussion”