{% load crispy_field from crispy_forms_field %} {% load blocktrans trans from i18n %} {% load whitespaceless from ext_theme_tags %} {% comment rst %} Rich select field template ========================== This template is used by the :py:class:`~readthedocs.core.forms.RichSelect` widget type to display a complex dropdown select. Normally, select fields are only a value and text choice option, but the :py:class:`~readthedocs.core.forms.RichSelect` widget type instead displays a FUI dropdown type with a number of additions, like an image, description, and an error description. This gives a field type where we can provide a reason why the choice is disabled, before the user tries to submit the form. To use this template, use the RichSelect class and :py:class:`~readthedocs.core.forms.RichChoice` data class to populate the from choices. A brief example is: .. code:: python choice = RichChoice(name="Foo", value="foo", error="Unavailable", image_url="...") field = forms.ChoiceField( ..., widget=RichSelect(), choices=[(choice.value, choice)], ) Attributes are defined on :py:class:`~readthedocs.core.forms.RichSelect` {% endcomment %} {% whitespaceless as form_data_bind %} {% if data_bind %} {{ data_bind }} {% elif "data-bind" in field.field.widget.attrs.keys %} {% for key, value in field.field.widget.attrs.items %} {% if key == "data-bind" %}{{ value }}{% endif %} {% endfor %} {% else %} semanticui: { dropdown: {}} {% endif %} {% endwhitespaceless %} {% whitespaceless as field_classes %} ui long fluid selection search dropdown {% if field.field.widget.attrs.readonly %}read-only{% endif %} {% if field.field.widget.attrs.multiple %}multiple{% endif %} field {% endwhitespaceless %} {# Use Knockout data binding, or set ``data-semanticui-dropdown`` which causes Knockout to skip this element #}
{{ field.as_hidden }}
{{ field.attrs.placeholder }}