title: How can I render an entity (choice <select>) field as a <ul> field in Twig?
body: <blockquote>
    <p>Symfony renders an <a href="http://symfony.com/doc/current/reference/forms/types/entity.html" rel="nofollow noreferrer"><code>entity</code> field type</a> like a <code>choice</code> dropdown - a <code>select</code>, basically. However, the CSS framework that I'm using defines a sort of 'select' as a <code>ul</code> and <code>li</code> as the options. The <a href="http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html" rel="nofollow noreferrer">Custom Field Type</a> documentation gives no help on this scenario.</p>
  </blockquote>
  
  <p>I'm converting my code from manual HTML rendering of the form dropdown to symfony form's version using twig and <code>form_widget()</code>. However, I want a <code>ul</code> and <code>li</code> instead of a <code>select</code>.</p>
  
  <p>The manual way of creating my dropdown is:</p>
  
  <pre><code>&lt;ul class='dropdown-menu'&gt;
      {% for locator in locators %}
          &lt;li&gt;
              &lt;a href="#" data-id="{{locator.getId() }}"&gt;
                  {{ locator.getName() }}
              &lt;/a&gt;
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>That's how I would render my dropdown manually before using symfony forms. It looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/77yfY.png" alt="custom css dropdown"></p>
  
  <p>I like it. I think it looks awesome. Now, if I'm using Symfony forms, I can just use this instead:</p>
  
  <pre><code>{{ form_start(form) }}
      {{ form_widget(form.locator) }} {# This is my locator dropdown #}
      {{ form_widget(form.target) }} {# Ignore this #}
  {{ form_end(form) }}
  </code></pre>
  
  <p>The problem is that this renders this instead:</p>
  
  <p><img src="https://i.stack.imgur.com/cIcqR.png" alt="symfony form select dropdown"></p>
  
  <p>I can't add my custom CSS here because this is rendered as a <code>select</code> instead of an unordered list and <code>li</code>s.</p>
  
  <p>In case it may help, here's my form type being built:</p>
  
  <pre><code>/**
   * {@inheritDoc}
   */
  public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;add('target')
              -&gt;add('locator', 'entity', [
                  'class'         =&gt; 'Application\Model\Entity\Locator',
                  'query_builder' =&gt; function(EntityRepository $repo) {
                      return $repo-&gt;createQueryBuilder('e');
                  },
                  'empty_value'   =&gt; 'Locator'
              ])
              -&gt;add('save', 'submit', ['label' =&gt; 'Save']);
  
      $builder-&gt;setAction($this-&gt;urlGenerator-&gt;generate('page_create_element', [
          'suiteId' =&gt; $options['suiteId'], 'pageId' =&gt; $options['pageId']
      ]))-&gt;setMethod('POST');
  }
  </code></pre>
  
  <p><strong>The Question</strong>: Is there any way I can have the form commands above auto-generate my ul / li requirement instead of selects, or do I have to render this manually instead and ignore the symfony forms component for this?</p>