File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
lib/active_admin/views/pages Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ a thin DSL on top of [Formtastic](https://github.com/justinfrench/formtastic):
66``` ruby
77ActiveAdmin .register Post do
88
9- form do |f |
9+ form title: ' A custom title ' do |f |
1010 inputs ' Details' do
1111 input :title
1212 input :published_at , label: " Publish Post At"
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ module Pages
55 class Form < Base
66
77 def title
8- assigns [ :page_title ] || I18n . t ( "active_admin.#{ normalized_action } _model" ,
9- model : active_admin_config . resource_label )
8+ if form_presenter [ :title ]
9+ render_or_call_method_or_proc_on ( resource , form_presenter [ :title ] )
10+ else
11+ assigns [ :page_title ] || I18n . t ( "active_admin.#{ normalized_action } _model" ,
12+ model : active_admin_config . resource_label )
13+ end
1014 end
1115
1216 def form_presenter
Original file line number Diff line number Diff line change 1616 OpenStruct . new ( params : params , helpers : helpers , assigns : { } )
1717 end
1818
19+ context "when :title is set" do
20+ it "should show the set page title" do
21+ page = ActiveAdmin ::Views ::Pages ::Form . new ( arbre_context )
22+ expect ( page ) . to receive ( :resource )
23+ expect ( page ) . to receive ( :form_presenter ) . twice . and_return ( { title : "My Page Title" } )
24+ expect ( page . title ) . to eq "My Page Title"
25+ end
26+ end
27+
1928 context "when page_title is assigned" do
2029 it "should show the set page title" do
2130 arbre_context . assigns [ :page_title ] = "My Page Title"
You can’t perform that action at this time.
0 commit comments