Arthur
Arthur

Reputation: 1548

Zend Framework 2 form annotation is ignored without an extra space

I spent hours banging my head against the wall with this. The labels for my form fields didn't appear no matter what.

Finally found that without the extra space where the cursor is (see image), all annotations get ignored. I'm using ZF 2.1.1 with Doctrine Common 2.2.3.

Am I doing something wrong? Or is this a bug in ZF or the Doctrine parser?

Eclipse screenshot

Works:

   class LoginForm
   {
   /** @Annotation\Type("text")
    * @Annotation\Options({"label":"Store ID:"})
    * @Annotation\Required(true)
    * @Annotation\Filter({"name":"StringTrim"})
    * @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
    */
   public $sStoreId;
   }

Fails, unless there is a space after /**:

   class LoginForm
   {
   /**
    * @Annotation\Type("text")
    * @Annotation\Options({"label":"Store ID:"})
    * @Annotation\Required(true)
    * @Annotation\Filter({"name":"StringTrim"})
    * @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
    */
   public $sStoreId;
   }

Upvotes: 5

Views: 1063

Answers (2)

Arthur
Arthur

Reputation: 1548

There seems to be no solution so use one of the workarounds provided in the original question:

  • add a space after /** (easy to forget)
  • put the first annotation or any text comment in the same line as /**

Upvotes: 2

Roman
Roman

Reputation: 2549

Because the annotation are using the php-doc standard, the first line is always for a comment/description. It must be given. If you provide no comment/description, leave the line empty.

Upvotes: 1

Related Questions