Use Form_for Or Simple_form_for Methods Without Any Form Tag In Rails

Posted by Weston Ganger on April 28, 2016

I wanted to use the form_for or simple_form_for input helpers without having a form tag.

I never thought you could use fields_for outside of form_for but you definitely can.

- fields_for @user do |f|
  = f.label :name, "Name"
  = f.text_field :email, "Email"

# OR If you use Simple_Form

- simple_fields_for @user do |f|
  = f.input :email

Now you can can have simple inputs that can be easily used anywhere.

Related External Links:

Posted in Rails and Tagged with rails simple_form forms 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts