View Source ExTeal.Fields.Select (ExTeal v0.27.0)

The Select field may be used to generate a drop-down select menu.

The select menu's options may be defined using the Select.options/2 function:

Select.make(:size)
|> Select.options(["Small", "Medium"])

Summary

Functions

Callback implementation for ExTeal.Field.make/2.

Define the options for the select field. The function accepts a list of options that are either strings or maps with of value and label keys. If the list members are strings, the value will be used for both the value and label of the <option> element it represents.

Callback implementation for ExTeal.Field.sanitize_as/0.

At times it's convenient to be able to search or filter the list of options in a select field. You can enable this by calling Select.searchable on the field

Functions

Callback implementation for ExTeal.Field.default_sortable/0.

Link to this function

display_using_labels(field)

View Source
Link to this function

make(name, label \\ nil)

View Source

Callback implementation for ExTeal.Field.make/2.

Define the options for the select field. The function accepts a list of options that are either strings or maps with of value and label keys. If the list members are strings, the value will be used for both the value and label of the <option> element it represents.

options are expected to be an enumerable which will be used to generate each respective option. The enumerable may have:

  • keyword lists - each keyword list is expected to have the keys :key and :value. Additional keys such as :disabled may be given to customize the option

  • two-item tuples - where the first element is an atom, string or integer to be used as the option label and the second element is an atom, string or integer to be used as the option value

  • atom, string or integer - which will be used as both label and value for the generated select

Optgroups

If options is a map or keyword list where the firs element is a string, atom, or integer and the second element is a list or a map, it is assumed the key will be wrapped in an <optgroup> and teh value will be used to generate <options> nested under the group.

This functionality is equivalent to Phoenix.HTML.Form.select/3

Callback implementation for ExTeal.Field.sanitize_as/0.

@spec searchable(ExTeal.Field.t()) :: ExTeal.Field.t()

At times it's convenient to be able to search or filter the list of options in a select field. You can enable this by calling Select.searchable on the field:

Select.make(:type) |> Select.options(~w(foo bar)) |> Select.searchable()

When using this field, Teal will display an input field which allows you to filter the list based on it's key.

Link to this function

with_options(field, options)

View Source