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.

Form Questions /

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

Dropdownfield, text alternative and 'required'


Go to End


2 Posts   1014 Views

Avatar
stellalie

Community Member, 10 Posts

6 October 2011 at 11:49am

I been struggling. Basically I would like design a form where the dropdown field is auto generated from existing database:

$f->push(new DropdownField('Extras',_t('CalendarDateTime.EXTRA','Extra', $this->getExtraOptions())));

Where getExtraOptions() returns for dropdown values. I would like this to be a required field, thus user will need to choose something from the dropdown menu. However, if user can't find best match in the dropdown, he/she will need to input the value in a textfield.

I was thinking to create a radiobox, if a value is selected then user need to choose a value from a dropdown, if other value is selected then user will need to put something on a text field.

How do I do this in Silverstripe?

Many thanks in advance.

Avatar
stellalie

Community Member, 10 Posts

7 October 2011 at 5:59pm

Oh well, I end up using front end jQuery validation instead. :S