Symfony dynamic forms
- by Asier
Hi there,
I started with a form, which is made by hand because of it's complexity (it's a javascript modified form, with sortable parts, etc). The problem is that now I need to do the validation, and it's a total mess to do it from scratch in the action using the sfValidator* classes.
So, I am thinking to do it using sfForm so that my form validation and error handling can be done more easier and so I can reuse this form for the Edit and Create pages.
The form is something like this:
<form>
<input name="form[year]"/>
<textarea name="form[description]"></textarea>
<div class="sortable">
<div class="item">
<input name="form[items][0][name]"/>
<input name="form[items][0][age]"/>
</div>
<div class="item">
<input name="form[items][1][name]"/>
<input name="form[items][1][age]"/>
</div>
</div>
</form>
The thing is that the sortable part of the form can be expanded from 2 to N elements on the client side. So that it has variable items quantity which can be reordered.
How can I approach this problem?
Any ideas are welcome,
thank you. :)