{% load material_form material_form_internal i18n l10n %}

{% part bound_field.field %}<div class="row"><dmc-autocomplete>
    <div{% attrs bound_field 'group' %}
        id="id_{{ bound_field.html_name }}_container"
        data-form-control="autocomplete"
        data-autocomplete-target="id_{{ bound_field.html_name }}"
        class="input-field autocomplete-field col s12{% if field.required %} required{% endif %}{% if bound_field.errors %} has-error{% endif %}"
    {% endattrs %}>
        {% part field prefix %}{% endpart %}{% part field control %}
        <input {% attrs bound_field 'value_widget' %}
            type="hidden"
            name="{{ bound_field.html_name }}"
            id="id_{{ bound_field.html_name }}"
            {% if bound_field.value != None %}value="{{ bound_field.value|unlocalize }}"{% endif %}
            {% endattrs %}>
        <input{% attrs bound_field 'widget' default field.widget.attrs %}
            id="id_{{ bound_field.html_name }}_autocomplete"
            type="{{ field.widget.input_type }}"
            {% if field.disabled %}disabled{% endif %}
            {% if bound_field.errors %}class="invalid"{% endif %}
            {% if bound_field.value != None %}value="{{ bound_field|modelchoice_value }}"{% endif %}
        {% endattrs %}>
        {% if not field.disabled %}
        <a class="input-field-action" href="#" title="{% trans 'Clear' %}">
            <i class="material-icons">clear</i>
        </a>{% endif %}
        {% endpart %}
        {% part field label %}
        <label{% attrs bound_field 'label' %}
            for="id_{{ bound_field.html_name }}_autocomplete"
            {% if bound_field.value != None and bound_field.value != '' %}class="active"{% endif %}
        {% endattrs %}>{{ bound_field.label }}</label>
        {% endpart %}
        {% part field help_text %}{% if field.help_text %}
        <small class="help-block">{{ bound_field.help_text }}</small>
        {% endif %}
        {% endpart %}{% part field errors %}
        {% if bound_field.errors %}{% include  'material/field_errors.html' %}{% endif %}
        {% endpart %}{{ hidden_initial }}
    </div>
</dmc-autocomplete></div>{% endpart %}
