BitstylesPhoenix.Form.ui_select

You're seeing just the function ui_select, go back to BitstylesPhoenix.Form module for more information.
Link to this function

ui_select(form, field, options, opts \\ [])

View Source

Renders <select> elements, with the associated <label>s, and any errors for that field. Uses the select form helper in Phoenix.HTML.Form.

Options

  • All options from above (see top level module doc).
  • All other options will be passed to the underlying Phoenix form helper

See the bitstyles select docs for examples of textareas and labels in use.

Select box

iex> safe_to_string ui_select(@user_form, :week, 1..2)
~s(<label for="user_week">Week</label><select id="user_week" name="user[week]"><option value="1">1</option><option value="2">2</option></select>)

Select box without label

iex> safe_to_string ui_select(@user_form, :week, 1..2, hidden_label: true)
~s(<label class="u-sr-only" for="user_week">Week</label><select id="user_week" name="user[week]"><option value="1">1</option><option value="2">2</option></select>)

Select box with options

iex> safe_to_string ui_select(@user_form, :preference, [{"Ducks", "ducks"}, {"Cats", "cats"}], label: "What do you like best?", label_opts: [class: "extra"])
~s(<label class="extra" for="user_preference">What do you like best?</label><select id="user_preference" name="user[preference]"><option value="ducks">Ducks</option><option value="cats">Cats</option></select>)