Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Forms again :-)

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2420 Views
  • Nemus
    Avatar
    Community Member
    20 Posts

    Forms again :-) Link to this post

    Hi!

    I'm wondering how exactly to implement radio buttons, check boxes and select/option items inside form that is added through pagetype? I'm looking into source code for these items but i'm still not clear how to use them (and a few experiments failed ).

    So simple code example (maybe to add this to the docs directly) for these would be really apreciated.

    10x

  • Simon
    Avatar
    Core Development Team
    27 Posts

    Re: Forms again :-) Link to this post

    Heya, I've created a simple recipe for creating and adding some of these form fields to your form.

    http://doc.silverstripe.com/doku.php?id=forms

    and

    http://doc.silverstripe.com/doku.php?id=ss2:forms:recipes

    Naming each form element the same as the objects static $db variable will automatically save them to the object when you run $form->saveInto($object) from your form action.

    Let me know if this helps

  • Nemus
    Avatar
    Community Member
    20 Posts

    Re: Forms again :-) Link to this post

    Can you please give me example how to create group of radio buttons on a form and group of checkboxes. Real code example, if possible. I'm still little lost on that. I managed to get form up and running but I need those elements.

    10x in advance!

  • Simon
    Avatar
    Core Development Team
    27 Posts

    Re: Forms again :-) Link to this post

    I've added an example to the optionsetfield page, which is the form field you use to create a set of radio buttons.

    The constructor is the same as a dropdown, so you pretty much just pass it a name, title and a array of source values.

    See this link for more information.
    http://doc.silverstripe.com/doku.php?id=optionsetfield

    2420 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.