diff options
author | Azul <azul@leap.se> | 2012-12-07 12:30:15 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-07 12:30:15 +0100 |
commit | a2d343619e752f62cb7e3445803e4491696af391 (patch) | |
tree | d479b9a11d69d2d4098b4e67058eb11f8ff34b32 /users/app/helpers | |
parent | af101adb7c66201e175642ff0ef99988b42d2df2 (diff) |
using normal requests for user updates except password
password requires ajax for secure remote password to work
Diffstat (limited to 'users/app/helpers')
-rw-r--r-- | users/app/helpers/users_helper.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb index dec8904..5d9eff7 100644 --- a/users/app/helpers/users_helper.rb +++ b/users/app/helpers/users_helper.rb @@ -1,22 +1,32 @@ module UsersHelper - def user_form_with(partial, legend, locals) - user_form do |f| - locals.reverse_merge! :legend => legend, :f => f + def user_form_with(partial, options = {}) + user_form(options) do |f| + options[:f] = f render :partial => partial, :layout => 'legend_and_submit', - :locals => locals + :locals => options end end - def user_form - html_class = 'form-horizontal user form ' - html_class += (@user.new_record? ? 'new' : 'edit') + def user_form(options) simple_form_for @user, - :validate => true, - :format => :json, - :html => {:class => html_class} do |f| + :html => user_form_html_options(options), + :validate => true do |f| yield f end end + + def user_form_html_options(options) + { :class => user_form_html_classes(options).join(" "), + :id => dom_id(@user, options[:legend]) + } + end + + def user_form_html_classes(options) + classes = %W/form-horizontal user form/ + classes << options[:legend] + classes << (@user.new_record? ? 'new' : 'edit') + classes.compact + end end |