Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Can I add fields dynamically to a form?

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

Page: 1
Go to End
Author Topic: 1134 Views
  • _Vince
    Avatar
    Community Member
    161 Posts

    Can I add fields dynamically to a form? Link to this post

    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?

  • ajshort
    Avatar
    Community Member
    244 Posts
  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: Can I add fields dynamically to a form? Link to this post

    Wow, that worked like a charm!

    Thank you very much (:

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