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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Set default selected value in a radio field in User Forms


Go to End


4 Posts   2661 Views

Avatar
nomen

Community Member, 52 Posts

7 April 2010 at 1:28am

Edited: 07/04/2010 1:29am

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

Forum Moderator, 5523 Posts

7 April 2010 at 12:11pm

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

Community Member, 52 Posts

7 April 2010 at 7:45pm

Edited: 08/04/2010 3:59am

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

Community Member, 57 Posts

29 February 2012 at 10:54am

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,