Skip to content

Form & Table Field Reference

coezbek edited this page Dec 16, 2021 · 4 revisions

Text Field

text_field :caption

Select Field

(With bonus enum handling)

resource_states = Resource.states.keys.map { |state| [state.humanize, state] }
select :state, resource_states

Static Field

static_field :updated_at, resource.updated_at

CheckBox Field

check_box :is_true?

Email Field

email_field :email

Telephone Field

telephone_field :mobile

Collection CheckBoxes

collection_check_boxes :resource_ids, Resource.all, :id, :name

Collection Radio Buttons

collection_radio_buttons :resource_id, Resource.all, :id, :name

Collection Select

collection_select :resource_id, Resource.all, :id, :name

optional

{ multiple: true }

Color Field

color_field :paint_color

Date Field

date_field :date_from

Date Select

date_select :date_to

DateTime Field

datetime_field :game_start

DateTime Select

datetime_select :game_start

File Field

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

month_field :season_start

Number Field

number_field :group_size

Password Field

password_field :password

Tag Select

 tag_select :post_tags

Text Area

 text_area :content

Time Field

 time_field :start_at

Time Select

 time_select :start_at

Time Zone Select

 time_zone_select :current_time_zone

URL Field

 url_field :site_url

Week Field

 week_field :during_week