summaryrefslogtreecommitdiff
path: root/users/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/helpers')
-rw-r--r--users/app/helpers/users_helper.rb30
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