0

I'm using ZF2 and AnnotationForms. This worked great for me until now.

I have this exception that I want to display three forms in one view.

Basically I do the following:

<form>
  <?php for field in form1: echo field ?>
  <?php for field in form2: echo field ?>
  <?php for field in form3: echo field ?>
  <input type="submit" />
</form>

My problem is that some of these forms have fields with the same name (eg. "city"). So some of the input data gets lost.

I thought about renaming the fields (name-attribute in HTML) but then the mapping in the action with $entity->setData() won't work...

Does anyone has an idea how I can solve this without the need to build my whole form staticly in plain html?

Ron
  • 22,128
  • 31
  • 108
  • 206
  • 1
    Ultimately this sounds like to be a case of where you'd actually want to use Zend\Form\Fieldset instead of Zend\Form\Form for the separate "Entities" - though i can't give you any concrete help on Annotation Stuff :S – Sam Mar 26 '13 at 15:38
  • See http://www.michaelgallego.fr/blog/2012/07/04/new-zendform-features-explained/ – Sam Mar 26 '13 at 15:49
  • Hm, seems like something I could use. But as always: Is there a way to combine it with annotation forms? – Ron Mar 27 '13 at 10:08
  • 1
    From what i can tell by the Code, the AnnotationBuilder only supports the `createForm()` method of `Zend\Form\Factory` and not the `createFieldset()`. Only going by this i would assume: **NO**. But i still suggest heading over to #zftalk and ask there, Maks3w, Bakura and Mwop himwelf might be the persons to ask, i guess. – Sam Mar 27 '13 at 10:32

1 Answers1

1

You can use ComposedObject annotation, this will actualy create fieldset from some other model/entity file. It's very good explainded here: http://devblog.x2k.co.uk/using-the-composedobject-zend-framework-2-form-annotation/

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Martin Vlach
  • 121
  • 2
  • 4