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.

Archive /

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

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

Forms again :-)


Go to End


4 Posts   3354 Views

Avatar
Nemus

Community Member, 20 Posts

21 November 2006 at 2:11pm

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

Avatar
Simon

Community Member, 27 Posts

22 November 2006 at 2:49pm

Edited: 22/11/2006 2:50pm

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 :-)

Avatar
Nemus

Community Member, 20 Posts

24 November 2006 at 3:25am

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!

Avatar
Simon

Community Member, 27 Posts

24 November 2006 at 9:48am

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