trustpoint.forms ================ .. py:module:: trustpoint.forms .. autoapi-nested-parse:: Contains classes and helpers for forms that can be used in the whole project. Classes ------- .. autoapisummary:: trustpoint.forms.DisableOptionsSelect Module Contents --------------- .. py:class:: DisableOptionsSelect(attrs = None, disabled_options = None) Bases: :py:obj:`django.forms.Select` A custom Select widget that allows disabling specific optionsm in a Django ChoiceField dropdown. Example usage: forms.ChoiceField( choices=..., widget=DisableOptionsSelect(disabled_options=['some_value']) ) .. py:attribute:: disabled_options :value: [] .. py:method:: create_option(name, value, label, selected, index, subindex = None, attrs = None) Create a single option dictionary for rendering. Overrides the default method to add the `disabled` attribute for options whose value is in `self.disabled_options`. :param name: Name of the form field. :param value: Value of the option. :param label: Display label for the option. :param selected: Whether the option is selected. :param index: Index of the option. :param subindex: Optional subindex for optgroups. :param attrs: Additional HTML attributes. :returns: A dictionary representing the option to render.