fix user form field order and autocompletion

This commit is contained in:
wvengen 2013-12-22 13:28:33 +01:00
parent df9cff0eee
commit 3e1d561a5e
3 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,5 @@
= simple_form_for([:admin, @user]) do |f| = simple_form_for([:admin, @user]) do |f|
= render 'shared/user_form_fields', f: f = render 'shared/user_form_fields', f: f, password_autocomplete: false
.form-actions .form-actions
= f.submit = f.submit
= link_to t('ui.or_cancel'), :back = link_to t('ui.or_cancel'), :back

View file

@ -6,7 +6,7 @@
= h(t('.user.title', user: show_user)) = h(t('.user.title', user: show_user))
%small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on) %small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on)
= simple_form_for(@current_user, :url => update_profile_path) do |f| = simple_form_for(@current_user, :url => update_profile_path) do |f|
= render :partial => 'shared/user_form_fields', :locals => {:f => f} = render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => false}
.form-actions .form-actions
= submit_tag t('ui.save'), class: 'btn' = submit_tag t('ui.save'), class: 'btn'
.span5 .span5

View file

@ -1,12 +1,15 @@
- if FoodsoftConfig[:use_nick]
-# use_nil option to user model validators break required mark
= f.input :nick, required: true
= f.input :first_name = f.input :first_name
= f.input :last_name = f.input :last_name
= f.input :email = f.input :email
-# need :required because :use_nil option on user model validators break the required mark
= f.input :nick, required: true if FoodsoftConfig[:use_nick]
-# you can disable password autocompletion by passing `password_autocomplete: false` to this partial
-# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion
- password_autocomplete = nil unless defined?(:password_autocomplete)
- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off'})
= f.input :password, :required => f.object.new_record?, input_html: passwd_opts
= f.input :password_confirmation, :required => f.object.new_record?, input_html: passwd_opts
= f.input :phone = f.input :phone
= f.input :password, :required => f.object.new_record?
= f.input :password_confirmation
= f.simple_fields_for :settings_attributes do |s| = f.simple_fields_for :settings_attributes do |s|
= s.simple_fields_for :profile, defaults: { inline_label: true } do |profile| = s.simple_fields_for :profile, defaults: { inline_label: true } do |profile|