title: How to set a decimal in symfony2
body: <p>I've been trying to simply set a field type to a decimal between 0 and 1 however no matter the configuration I have, doctrine always rounds my decimal from my form field to the nearest whole number. </p>
  
  <p>My entity:</p>
  
  <pre><code>/**
   * @var integer
   *
   * @Assert\Range(
   * min=0,
   * max=1,
   * minMessage = "this must be greater than or equal to 0.",
   * maxMessage = "this must be less than or equal to 1."
   * )
   * @ORM\Column(name="nuetu", type="decimal", precision=2, scale=1, nullable=true)
   */
  private $nuetu;
  </code></pre>
  
  <p>My Field Type:</p>
  
  <pre><code>        -&gt;add('nuetu', 'integer', array(
              'scale' =&gt; 1,
              'attr' =&gt; array(
                  'min' =&gt; 0,
                  'max' =&gt; 1,
                  'step' =&gt; '.1',
              ),
              'label' =&gt; 'Lef a nuetu',
              'required' =&gt; false,
          ))
  </code></pre>
  
  <p>My Twig:</p>
  
  <pre><code>{{ form_row(form.nuetu, {'type': 'number'}) }}
  </code></pre>
  
  <p>I've also tried <code>{{ form_row(form.nuetu) }}</code> &amp; without using <code>assert</code> and without declaring <code>precision</code> or <code>scale</code> in my entity annotations.</p>
  
  <p>My goal is to persist the number to the database as (0.3 or 0.8). </p>
  
  <p>I've looked at these questions but I have been unsuccessful:</p>
  
  <p><a href="https://stackoverflow.com/questions/18512612/what-is-the-right-way-to-define-annotation-for-decimal-type-in-doctrine2">What is the right way to define annotation for DECIMAL type in Doctrine2</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10979090/rounded-decimal-in-edit-form-symfony2-doctrine2">Rounded decimal in edit form Symfony2 + Doctrine2</a></p>
  
  <p><a href="http://symfony.com/doc/2.7/reference/forms/types/integer.html" rel="nofollow noreferrer">http://symfony.com/doc/2.7/reference/forms/types/integer.html</a></p>
  
  <p><a href="http://symfony.com/doc/2.7/reference/forms/types/number.html#scale" rel="nofollow noreferrer">http://symfony.com/doc/2.7/reference/forms/types/number.html#scale</a></p>