LoginSignup
3
10

More than 3 years have passed since last update.

form_forの種類

Posted at

form_forとは

railsで情報を送信するためのヘルパーメソッドです。

そのため多くのrailsアプリケーションで使用されます。

基本構文

簡単なフォームの書き方

◯◯◯.haml
form_for(モデルオブジェクト , オプション) do |f|
  フォームコントロールの設置

form_forの種類

メソッド名 説明
check_box チェックボックス
color_field 色の入力欄
date_field 日付の入力欄
datetime_field 日時の入力欄(グローバルタイム)
datetime_local_field 日時の入力欄(ローカルタイム)
email_field emailアドレスの入力欄
fields_for form_forの中で別のモデルを指定したフォーム
file_field 画像や文章などのファイルを選択するフォーム
hidden_field 隠しフィールドの生成
label ラベルの生成
month_field 月の入力欄
number_field 数値入力欄
password_field パスワード入力欄
telephone_field,phone_field 電話番号入力欄
radio_button ラジオボタンの生成
range_field 範囲選択バー
search_field 検索ボックスフォーム
text_area 文字列入力欄
text_field 文字列入力欄
time_field 時間入力欄
url_field URL入力欄
week_field 週の入力欄
submit 送信ボタン

以上簡単な使い方と種類です

3
10
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
10