Select
Sort of a button for picking a single value
Includes a Ruby component and corresponding Rails helper
RubyExample
<%= nk_select "journey", "direction", %w[North East South West], value: "South" %>
API tries to match Rails' own select()
helper.
Form use
To use in forms, it's easiest to use the Form Builder.
f.select
tries to match Rails' own API.
For extra convenience use the f.field
method.
<%= nk_form_for :race do |f| %>
<%= f.field :driver,
options: %w[David Tobi],
value: "David",
as: :select,
label: "Driver",
description: "Who's foot is on the pedal?" %>
<% end %>
Usage
NB: While select
supports Rails' API, using f.field
is recommended.
| ||
---|---|---|
Property | Default | Description |
compat_object_name | nil | API compatibility Relevant object |
compat_method | nil | API compatibility Object attribute |
options | nil |
List of [label, value] pairs
|
compat_options | {} | API compatibility "Options" as a hash |
include_blank | false | Whether to include a blank option |
prompt | nil | Label for blank option |