ZF2 Doctrine Form Annotation Type Select

i have a problem with the annotation for a select Element. I Always get an input field.

<div class="form-group "><label>test:</label><input type="number" name="test" class="form-control" value="1"></div>

Here is my Annotation.

 * @var integer
 * @ORM\Column(name="test", type="integer", nullable=false)
 * @Annotation\Type("Zend\Form\Element\Select")
 * @Annotation\Filter({"name":"StringTrim"})
 * @Annotation\Options({"label":"test:", "value_options":{"0":"yes","1":"no"}})
private $persistent = '0';

did i forget something ?

kind regards :)

UPDATE 2014-04-23

in my action i create the form with

    $builder = new DoctrineAnnotationBuilder($entityManager);
    $form = $builder->createForm( $user );
    $form->setHydrator(new DoctrineHydrator($entityManager,'Test\Entity\Test'));

and this is my view

    $form = $this->form;
    $form->setAttribute('action', $this->url('user/edit', array('id' => $this->id))); //'contact/process'));
    $form->setAttribute('method', 'post');

    echo $this->form()->openTag($form);
    echo $this->formCollection($form);
    echo $this->form()->closeTag();


Check the answer here...

That might help, might also not help, but at least worth a try...

I know this is a bit old, but for reference, this is the entity property docblock within a Doctrine 2 Annotated entity that works for me to render a fixed list select:

 * @var string
 * @ORM\Column(name="layout", type="string", length=45, nullable=true)
 * @Annotation\Type("Zend\Form\Element\Select")
 * @Annotation\Options({
 *   "label":"Layout:",
 *   "value_options":{"":"", "one-page":"One Page", "multi-page":"Multi-page"}
 * })    
private $layout;

Using latest ZF 2.3.*.

I have the same problem. Want just through Annotation get my Select box built. I think that Hydrator does not do it really (Doctrine 2 ORM v 1,* and ZF2.5).

Just use Iterator and use


use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Annotation;
     * @var \Backend\Entity\Mastercategory
     * @Annotation\Type("Zend\Form\Element\Select")
     * @ORM\ManyToOne(targetEntity="Backend\Entity\Mastercategory")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="sub_pid", referencedColumnName="id")
     * })
    private $subPid;


//mastercategories  is my Object EntityClass actually with getter_setter
$arr = new \ArrayIterator($mastercategories);
        $masterToArr = array();
        while ($arr->valid())
            $mid = $arr->current()->getId();
            $mname = $arr->current()->getMasterName();
            $masterToArr[$mid] = $mname;
        $form->get('subPid')->setOptions(array('type' => 'select', 'value_options' => $masterToArr));


<?php echo $this->formSelect($form->get('subPid')); ?>

I know this is not a good Idea to fill out Controller with stuff like this but it works fine.

Need Your Help

Save results of foreach loop in a matrix

r foreach

I am trying to adapt a for loop to use it in parallel as a foreach loop. For the for loop I create an empty matrix then fill it with the values generated by the for loop. But this approach doesn't ...