-
Notifications
You must be signed in to change notification settings - Fork 177
Form & Table Field Reference
The table DSL accepts the following methods:
column(field, proc=nil, options={}, &block) # Adds a column with the given field name to the table.
actions(options={}, &block) # Appends default actions and additional actions for table entries (e.g. delete)
row(options={}, &block) # Unclear what this does
selectable_column(options={}) # Adds a column by which table rows can be selected
If no proc/block are given, then the field name is used as the database field name.
If a proc
or block
is given, this is passed the instance to return the value to show. Please note that if you perform any database access here, these are going to be executed for each instance (row) which is currently visible in the table. This is also the reason why sorting is not available when you use proc
or block
(it would have to evaluate the result for each database entry).
If both a proc
and block
are given, the proc
takes precedence.
Options:
align
link
sort
TODO
text_field :caption
(With bonus enum handling)
resource_states = Resource.states.keys.map { |state| [state.humanize, state] }
select :state, resource_states
with selected value
resource_states = Resource.states.keys.map { |state| [state.humanize, state] }
select :state, resource_states, { selected: resource.state }
static_field :updated_at, resource.updated_at
check_box :is_true?
email_field :email
telephone_field :mobile
collection_check_boxes :resource_ids, Resource.all, :id, :name
collection_radio_buttons :resource_id, Resource.all, :id, :name
collection_select :resource_id, Resource.all, :id, :name
optional
{ multiple: true }
color_field :paint_color
date_field :date_from
date_select :date_to
datetime_field :game_start
datetime_select :game_start
file_field :image
To allow multiple files to be uploaded:
file_field :attachments, multiple: true
The file_field helper works the same as the corresponding Rails form helper (Source: Issue 272).
month_field :season_start
number_field :group_size
password_field :password
tag_select :post_tags
text_area :content
time_field :start_at
time_select :start_at
time_zone_select :current_time_zone
url_field :site_url
week_field :during_week