Skip to content

Commit

Permalink
Fix FormBuilder errors_summary rendering within page (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov authored Feb 10, 2024
1 parent 9ad30fd commit 3e78c44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/helpers/polaris/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FormBuilder < ActionView::Helpers::FormBuilder

delegate :render, :pluralize, to: :template

def errors_summary
def errors_summary(within: :container)
return if object.blank?
return unless object.errors.any?

Expand All @@ -19,7 +19,7 @@ def errors_summary
render Polaris::BannerComponent.new(
title: title,
status: :critical,
within: :container,
within: within,
data: {errors_summary: true}
) do |banner|
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<%= form_with(model: product, builder: Polaris::FormBuilder) do |form| %>
<%= polaris_layout do |layout| %>
<%= layout.with_section do %>
<%= form.errors_summary %>
<%= polaris_card do %>
<%= form.errors_summary %>
<% end %>
<% end %>
<%= layout.with_section do %>
<%= form.errors_summary do %>
<%= form.errors_summary(within: :page) do %>
with custom content
<% end %>
<% end %>
Expand Down

0 comments on commit 3e78c44

Please sign in to comment.