Rails simple_form error: false -


in app have form looks this

= simple_form_for @user |f|   = f.input :name, error: false   = f.input :surname, error: false 

is there way avoid repetitions (error: false)?

if they're of same type, should work:

= simple_form_for @user |f|   - [ :name , :surname ].each |field|     = f.input field, error: false 

if not, use hash or something, instead of array, , specify type, well.

it appears simple form has following option:

if want pass same options inputs in form (for example, default class), can use :defaults option in simple_form_for. specific options in input call overwrite defaults:

<%= simple_form_for @user, defaults: { input_html: { class: 'default_class' } } |f| %>   <%= f.input :username, input_html: { class: 'special' } %>   <%= f.input :password, input_html: { maxlength: 20 } %>   <%= f.input :remember_me, input_html: { value: '1' } %>   <%= f.button :submit %> <% end %> 

from https://github.com/plataformatec/simple_form

so, in case:

= simple_form_for @user , defaults: { error: false } |f|   = f.input :name   = f.input :surname 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -