title: Symfony2: Overriding a built-in field type with a custom field type having the same name
body: <p>As per <a href="http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html" rel="nofollow">this article</a> on the Symfony docs, I've created a custom field type, set it up in <code>services.yml</code>, and I am able to use it successfully.</p>
  
  <p>For example, I create a custom field named <code>customdate</code> as follows, which works perfectly:</p>
  
  <pre><code># src/Acme/DemoBundle/Resources/config/services.yml
  services:
      acme_demo.form.type.date:
          class: Acme\DemoBundle\Form\Type\DateType
          tags:
              - { name: form.type, alias: customdate }
  </code></pre>
  
  <p>However, if I try to name my custom field as <code>date</code> (which is the same as <a href="http://symfony.com/doc/current/reference/forms/types/date.html" rel="nofollow">an existing Symfony field type</a>, since this is what I am trying to override), as shown below, then Symfony completely ignores my custom field, and defaults to the built-in Symfony <code>date</code> field type instead:</p>
  
  <pre><code># src/Acme/DemoBundle/Resources/config/services.yml
  services:
      acme_demo.form.type.date:
          class: Acme\DemoBundle\Form\Type\DateType
          tags:
              - { name: form.type, alias: date }
  </code></pre>
  
  <p>I've checked that my <code>getName()</code> function returns the correct name, matching up with the alias I provided in <code>services.yml</code>.</p>
  
  <p>The code in which I make use of the above services follows below.</p>
  
  <p>This works:</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;add('date', 'customdate')));
  }
  </code></pre>
  
  <p>This does not work: (or rather, Symfony uses the built-in field type instead of mine)</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;add('date', 'date')));
  }
  </code></pre>
  
  <p>I should note that if I replace the 'customdate' or 'date' with a manually-created object such as <code>new Date()</code> then it works fine. The problem appears to be specifically that Symfony prefers its built-in field types over the ones that are specified in <code>services.yml</code>.</p>
  
  <p><strong>My question:</strong> is there any way to override built-in Symfony field types with custom field types that have the same name? Clearly, from what I described above, Symfony appears to ignore any custom fields that are aliased to the same name as a built-in Symfony field type. Is there any way around this?</p>