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

Can I add fields dynamically to a form?


Go to End


3 Posts   2325 Views

Avatar
_Vince

Community Member, 165 Posts

8 May 2010 at 9:18pm

Say I have a table of tradesmen, and a table of job descriptions ("plumber", "electrician", etc)

I would like to let users search for tradesmen by job description.

Ideally, the form would display all the available job descriptions with a checkbox next to each one, so the users could pick several job descriptions at the same time.

The problem is, I don't know how many job descriptions there will be (there's supposed to be a maximum of 30) and what I would like to do is:

Query the database and get all the available job descriptions
Loop through the records
For each record in the loop, create a checkbox in the form.

Is there any way of doing this?

If it was straightout php I guess I could echo everything onto the page, but I'm not sure how to do this in SilverStripe? Any suggestions?

Avatar
ajshort

Community Member, 244 Posts

8 May 2010 at 10:10pm

Avatar
_Vince

Community Member, 165 Posts

8 May 2010 at 11:09pm

Wow, that worked like a charm!

Thank you very much (: