Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Form Template with Dynamic Number of Fields

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

Page: 1
Go to End
Author Topic: 570 Views
  • okotoker
    Avatar
    Community Member
    41 Posts

    Form Template with Dynamic Number of Fields Link to this post

    I am trying to figure out how to render out a custom template from a form I add fields to based on an array. So for every element in the array I push a new field into the fieldset I use for the form.

    What I am trying to accomplish is a cart review page with all the products added to a cart. Each item in the list has a remove button to eliminate it from the cart, a field with a number to change the amount and a update button.

    So I can't just push all the fields into the form as they won't be formatted into the table I need. I can see when you render out a custom template for a form how you specify a field with a specific name should go here and so on. This won't work if I don't know the amount of fields ahead of time.

    Maybe there is a better way to do this?

    Thanks

  • okotoker
    Avatar
    Community Member
    41 Posts

    Re: Form Template with Dynamic Number of Fields Link to this post

    I accomplished what I needed by pushing in literalfields. It seems like this wouldn't be the preferred way of handling this, so even though I got it going I would really like to hear what the better way to achieve this would be.

    Thanks

  • okotoker
    Avatar
    Community Member
    41 Posts

    Re: Form Template with Dynamic Number of Fields Link to this post

    So I should read things more carefully. At the bottom of the forms docs it says to use <% control Fields %>.......

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