Listes déroulantes

Documentation du tag

Returns a select item. Prefer the use of an actual form (see documentation)

Takes a dict as parameter, with the following structure:

data_dict = {
    "id": "The html id of the select item",
    "label": "Label of the select item",
    "onchange": "(Optional) Action that happens when the select is changed",
    "selected": "(Optional) If the item is selected",
    "default": { # Optional
        "disabled": "If the item is disabled",
        "hidden": "If the item is hidden",
    },
    "options": [
        {"text": "Option 1", "value": 1 },
        {"text": "Option 2", "value": 2 }
    ],
    "extra_classes": "(Optional) string with names of extra classes"
}

Relevant extra_classes:

  • village-sidemenu--sticky: Makes the menu sticky
  • village-sidemenu--sticky-full-height: Makes the menu take the full height of the screen
  • village-sidemenu--right: Moves the menu to the right side of the screen

All of the keys of the dict can be passed directly as named parameters of the tag.

Tag name: village_select

Usage: {% village_select data_dict %}

Exemples

Données

{'default': {'disabled': True, 'hidden': True, 'text': 'Choisissez une option'},
 'id': 'select-example-id',
 'label': 'Label de l’élément select',
 'onchange': 'console.log(value)',
 'options': [{'text': 'Option 1', 'value': 1},
             {'text': 'Option 2', 'value': 2}]}

Résultat