1.3 產生表單元素的輔助方法
Rails 提供一系列的輔助方法,用來產生表單元素,像是多選方框(checkboxes)、文字欄位(text fields)以及單選按鈕(radio button)。名字以
_tag 結尾的輔助方法(譬如 text_field_tag 與 check_box_tag)只會產生一個 <input> 元素。這些輔助方法的第一個參數都是 input 的名稱(name)。表單送出時,name 會與表單資料一起送出,使用者輸入的資料會存在 params Hash 裡,可在 Controller 取用。舉個例子,若表單的 input 是 <%= text_field_tag(:query) %>,則可在 Controller 用 params[:query] 來獲得使用者的輸入。http://rails-practice.com/content/Chapter_3/3.2.html
rails 搜尋表單實做方法 檢體
form_tag
看此篇學會
http://www.saalonmuyo.com/2010/01/27/using-form_tag-in-ruby-on-rails/
http://stackoverflow.com/questions/10489314/how-can-i-use-form-tag-as-opposed-to-form-for-in-this-file
英文
api
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag
沒有留言:
張貼留言