Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Set default selected value in a radio field in User Forms


Reply

4 Posts   1733 Views

Avatar
nomen

7 April 2010 at 1:28am (Last edited: 7 April 2010 1:29am), Community Member, 52 Posts

Hi all:

I´m using User Forms (SS 2.4 RC1, userforms-trunk-r101443).
I created a form in admin panel.
Now I create a radio field with three options. I want that the third option is checked by default.
In another project, In version 2.1, I did the same thing and it was so easy: when you were creating the options, you could indicate whether or not it was the default. But now there is not a way to do it.

So the question is: how can I set the default selected value in a radio field?

Thanks in advance.

Avatar
Willr

7 April 2010 at 12:11pm Forum Moderator, 5511 Posts

Currently no way of doing it. However it is on my development todo list for the module. Not just for radio buttons but to add the checked functionality to checkboxes and dropdowns etc.

Will be on my todo list http://open.silverstripe.org/ticket/5058 for 0.3

Avatar
nomen

7 April 2010 at 7:45pm (Last edited: 8 April 2010 3:59am), Community Member, 52 Posts

Hi Willr:

And there is no way to set it by code? Can I do something like...

class MyContactForm_Controller extends UserDefinedForm_Controller {

   
   function Form()
   {
      $form = parent::Form();
// Do something to select a value in radio field
      return $form;
   }
}


Thanks in advance.

Avatar
SnowBoarder82

29 February 2012 at 10:54am Community Member, 52 Posts

Hi Willr,

Was reading this post by Nomen while searching the forum to see the best way to add default text to a text field in your userform module. What do you think would be the best way to go about this?

Thank you,