lib/active_admin/views/pages/form.rb in activeadmin-0.6.6 vs lib/active_admin/views/pages/form.rb in activeadmin-1.0.0.pre1

- old
+ new

@@ -3,46 +3,56 @@ module Pages class Form < Base def title - assigns[:page_title] || I18n.t("active_admin.#{params[:action]}_model", - :model => active_admin_config.resource_label) + assigns[:page_title] || I18n.t("active_admin.#{normalized_action}_model", + model: active_admin_config.resource_label) end def form_presenter - active_admin_config.get_page_presenter(:form) || default_form_config + active_admin_config.get_page_presenter(:form) || default_form_config end def main_content - form_options = default_form_options.merge(form_presenter.options) + options = default_form_options.merge form_presenter.options - if form_options[:partial] - render(form_options[:partial]) + if options[:partial] + render options[:partial] else - active_admin_form_for(resource, form_options) do |f| - instance_exec f, &form_presenter.block - end + active_admin_form_for resource, options, &form_presenter.block end end private def default_form_options { - :url => default_form_path, - :as => active_admin_config.resource_name.singular + url: default_form_path, + as: active_admin_config.param_key } end def default_form_path resource.persisted? ? resource_path(resource) : collection_path end def default_form_config ActiveAdmin::PagePresenter.new do |f| + f.semantic_errors # show errors on :base by default f.inputs f.actions + end + end + + def normalized_action + case params[:action] + when "create" + "new" + when "update" + "edit" + else + params[:action] end end end end