简体   繁体   中英

What does f.input in a rails form do?

I started to program with Rails after i finished some lessons in Ruby. When i looked at someone's code I got confused. It looked like he makes some form using Rails but I just can't understand how it works. Well just take a look on the code... Hopefully you can help me to understand this:

=f.inputs do
   =f.input :type, :as => :transmission, :label => false
   =create_submit_link('Do something',:id=>'transmit')

Now the f.input row will print me 3 rows of following stuff: (row 1): radio_button | labeltext | text_field; (row 2): 1x radio_button |labeltext| number_field; (row 3): radio_button |labeltext|

How is that possible? :O

f.inputs is not defined in rails. You may be using "simple-form" gem. Simple Form has various views helpers to generates html contents. It has various method such as: text , radio , email however :as => :transmission options seems to be user defined as its not defined in "simple form" also. You can take look at https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/action_view_extensions/form_helper.rb . f.input work same as f.textbox or similar to rails but it has much more options than bare rails html helpers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM