Jump to:

10930 Posts in 2613 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Set default selected value in a radio field in User Forms

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1698 Views
  • nomen
    Avatar
    Community Member
    52 Posts

    Set default selected value in a radio field in User Forms Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Set default selected value in a radio field in User Forms Link to this post

    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

  • nomen
    Avatar
    Community Member
    52 Posts

    Re: Set default selected value in a radio field in User Forms Link to this post

    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.

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Set default selected value in a radio field in User Forms Link to this post

    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,

    1698 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.