-3

My form type is as follows:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('Name')
            ->add('Occupation');
    }

My edit.html.twig is as follows:

{% block main %}
    <form action="{{ path('admin_artists_edit', {'id': artist.id}) }}" method="post" {{ form_enctype(artistForm) }}>
        {{ form_errors(artistForm) }}

        {{ form_row(artistForm.name) }}

        {{ form_rest(artistForm) }}
        <input type="submit" />
    </form>
{% endblock %}

Is there any way to make the Occupation field as a searchable drop down list?Any ideas would be aprreciated

Alvin Bunk
  • 7,621
  • 3
  • 29
  • 45
Developp
  • 29
  • 10

1 Answers1

0

Issue is resolved :

{{ form_widget(artistForm.occupation, { 'attr': {'class': 'searchabledropdown'} }) }}


        {% block stylesheets %}
            <link href="{{ asset('css/select2.css') }}" type="text/css" rel="stylesheet" />
        {% endblock %}
        {% block javascripts %}
            <script src="{{ asset('js/select2.js') }}"></script>
        {% endblock %}

    <script type="text/javascript">
        $(document).ready(function() {
            $(".searchabledropdown").select2();
        });
    </script>
Developp
  • 29
  • 10