You definitely need to create 5 separate forms in your actions as one 
default value is different for each as you've said (changing a field 
value in the template is not a good thing IMO).

To have unique ids, and to be able to validate/save your forms, you need 
to change the name format of each form:

$form[$i]->setNameFormat('form['.$i.'][%s]');

This way, you will have ids of the form: form_1_fieldname, 
form_2_fieldname, ...

And when validating your form, you will be able to manage each form 
separately:

$form[$i]->bind($request->getParameter('form['.$i.']'));

You can also use a FormForEach to have a single form. Then, you only 
have 1 form to create and 1 form to validate and save.

Fabien

tom ee wrote:
> Hi everyone,
> 
> Hopefully someone will have come across this scenario before and will
> be happy to share their knowledge.
> 
> I am developing a CMS, which re-uses a form in a template. The form
> has a text input, and a couple of hidden fields. The form is used 5
> times in the view template, with a different value for one of the
> hidden fields.
> 
> I can set the default value for this hidden field in my template, by
> cheekily calling:
> 
> $itemsform->setDefault('type', $type);
> 
> which works just fine.
> 
> However, the 5 separate forms all have the same Id's for the fields,
> which causes issues (each of the 5 input fields has an auto-suggest
> style ajax call, + the page doesn't validate).
> 
> How can I change the id for the fields in the view? I have seen the
> funtion setIdFormat($format), but it only works in the configure()
> function, and doesn't appear to do anything.
> 
> Or, do I need to create 5 separate forms in my action?
> 
> Thanks in advance :-)
> > 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to