Rails Form徐赫謙
View Slide
Rails FormBasic
Built-in• form_tag• form_for
form_tag• 不主動對應Model• 適⽤用於不需要與Model直接互動的表單
form_for• 與Model有直接的關係• 需要帶⼊入Resource• 欄位名稱⼀一定要是能存取的屬性
field helpers (tag)• text_field_tag• text_area_tag• hidden_field_tag• label_tag• select_tag• submit_tag• check_box_tag• radio_button_tag• field_set_tag• password_field_tag• ... more
field helpers (for)• text_field• text_area• hidden_field• label• select• submit• check_box• radio_button• fields_for• password_field• file_field• ... more
Example• form_for: https://gist.github.com/3507380#file_form_for.html.erb• form_tag: https://gist.github.com/3507380#file_form_tag.html.erb
Nested Form可以輕易的建⽴立嵌套Model的Records
Nested Formhttps://gist.github.com/3507380#file_survey.rb
Built-in
Rubygem
Simple Form
https://gist.github.com/3507380#file_simple_new.html.erb