I'm trying to create a zend form that references separate fieldsets entirely using annotations. I'm doing this using the ComposedObject
annotation. But no annotations (like \type or \attributes) inside the fieldset classes seem to be added/used.
Only annotations from the parent form are used.
For example, if I were to add @Annotation\Type("number")
to the parent Form class, then the input type would be correctly set to type="number"
. However, if I were to add @Annotation\Type("number")
to the fieldset class, then nothing, nada, I get type=""
instead. And I can't work out why!!
Here is my parent form:
<?php
namespace Permits\Form;
use Zend\Form\Annotation as Form;
/**
* @Form\Name("trips")
* @Form\Attributes({"method":"post"})
* @Form\Type("Permits\Form\Form")
*/
class TripsForm
{
/**
* @Form\Name("numberOfTrips")
* @Form\ComposedObject("Permits\Form\Model\Fieldset\numOfTrips")
*/
public $numberOfTrips = null;
}
Here is the fieldset class Permits\Form\Model\Fieldset\numOfTrips
:
<?php
namespace Permits\Form\Model\Fieldset;
use Zend\Form\Annotation as Form;
/**
* @Form\Name("numOfTrips")
* @Form\Attributes({
* "class": ""
* })
*/
class numOfTrips
{
/**
* @Form\Attributes({
* "class" : "input--trips",
* })
* @Form\Options({
* "label": "",
* })
* @Form\Type("number")
*
*/
public $numOfTrips = null;
}
I'm creating the form using:
$builder = new AnnotationBuilder();
$form = $builder->createForm('Permits\Form\TripsForm');
I would be grateful for any help or direction.