3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

フォーム関連のメソッド

Last updated at Posted at 2015-01-16

form_for/form_tag フォーム

form_for/form_tagメソッドは、いずれも

タグを生成するためのメソッド。
・form_forは特定のモデルオブジェクトを編集するのに特化したメソッド
基本的にはform_forを使用してモデルの編集を行う(form_tagでもできるが基本はこちら)

・form_tagはモデルに関連しない汎用的なフォームを生成するためのメソッド
例えば、検索キーワードや条件を入力するフォームは、一般的にモデルに関連づかないためform_tagを使用する

leabel ラベル

text_field テキストボックス

password_field パスワード入力ボックス

text_area テキストエリア

file_field ファイル選択ボックス

check_box チェックボックス

radio_button ラジオボタン

select 選択ボックス/リストボックス

collection_select データベースの情報をもとに選択を生成する

group_collection_select 選択ボックスの選択肢をグループ化する

options_for_select 配列/ハッシュを生成する

options_from_collection_for_select データベースから動的に生成する

select_tag モデルと関連づかない選択ボックスを生成する

hidden_field 隠しフィールド

email_field メールアドレス入力ボックス

number_field 数値入力ボックス

range_field 範囲バー

search_field 検索ボックス

telephone_field 電話番号入力ボックス

url_field URL入力ボックス

color_field 色選択ボックス

date_field 日付入力ボックス

datetime_field 日付時刻入力ボックス

datetime_field 日付時刻入力ボックス(ローカル)

time_field 時刻入力ボックス

month_field 月入力ボックス

week_field 週入力ボックス

submit サブミット

fields_for form_for ブロック配下のサブフォーム

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?