title: PHP Symfony: How to access a getter-Constraint in a form template?
body: <p>I created a simple entity-class that holds some properties and a public getter-Method that executes some stuff and returns true or false.</p>
  
  <pre><code>class Item {
      public prop1;
      public prop2;
  
      public function isGetterConstraint() {
          return true // or false based on some calculations
      }
  }
  </code></pre>
  
  <p>Then I defined the constraints for that class in the validation.yml:</p>
  
  <pre><code>Foo\MyBundle\Entity\Item:
      properties:
          prop1:
              - NotBlank: ~
          prop2:
              - NotBlank: ~
      getters:
          getterConstraint:
              - "True": { message: "zu" }
  </code></pre>
  
  <p>That's what you see in many examples, but I have not found out how to access this getter-constraint in a form either within the controller or the twig template. In my case I do need it within the template.</p>
  
  <p>If I define my FormType like that</p>
  
  <pre><code>class ClientType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('prop1', 'text')
              -&gt;add('prop2', 'text');
      }
  
      public function getName()
      {
          return 'item';
      }
  
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Foo\MyBundle\Entity\Item',
          ));
      }
  }
  </code></pre>
  
  <p>and my Controller like that</p>
  
  <pre><code>class ItemController extends Controller {
      public function createAction(Request $request) {
          $item = new Item();
  
          $form = $this-&gt;buildForm($item);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isValid()) {
              // do some nice things like saving the data
          }
          return $this-&gt;render('FooMyBundle:Item:form.html.twig', array('form' =&gt; $form-&gt;createView());
      }
  }
  </code></pre>
  
  <p>the form does not know about the getter-constraint and I can't access it like I'm used to with property constraints:</p>
  
  <pre><code>// form.html.thwig
  
  {% if form.prop1.vars.errors %}{% endif %} // works
  
  {% if form.getterConstraint.vars.errors %}{% endif %} // doesnot work
  </code></pre>
  
  <p>Is there a way to add the getter constraint to the FormType or what do I have to do to make the form consider this constraint when validating the data and expose the result to the controller or template?</p>