3 ms·
Just use simple_form my friend! = simple_form_for @user, html: { class: 'form-horizontal' } do |f| = f.error_notification .form-inputs
by sergiotapia 13y ago
Just use simple_form my friend!
= simple_form_for @user, html: { class: 'form-horizontal' } do |f|
= f.error_notification
.form-inputs
= f.input :username, label: "Enter your username:", required: true
= f.input :password, label: "Enter your password.", required: true
.form-actions
= f.button :submit, "Save Changes", class: 'btn btn-primary'
Note though that this is a huge benefit of using simple_form _in addition_ to Slim.
- pothibo 13y agoI really wanted to avoid going in a discussion between gems trying to replace FormBuilder but I feel there needs to be some clarification. I have used simple_form, and I have used many different gems in the past. Simply saying that using simple_form solves every issues completely misses the point. There's a lot of forms out there that are built dynamically that needs a lot of conditions and evaluations to build the gems. CSS class can be added/removed depending on the current status of the user. This kind of things CANNOT be easily done with simple_form. For example, what if I need to add a class to the form if the user is an admin? Would you create a helper method for that? Or a ternary condition? If I mentioned simple_form in the very beginning of the article, it's possible that I did it so I would avoid this kind of facile counter-argument. I guess I was wrong.
- midas007 13y agoIt's a toolbox, each gem has unique strengths and weaknesses. If using ActiveAdmin, it's likely that large projects that include external apps already require simpleform and/or formtastic in addition to form_for/formbuilder. Whatever works best for a given situation / is easiest / most maintainable gets my vote.