Skip to content

Commit

Permalink
Configure the form builder globally
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Nov 19, 2024
1 parent 41a75ec commit 1b7fb2a
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<%= form_with scope: :additional_document_validation_request,
url: additional_document_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @additional_document_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :description_change_validation_request,
url: description_change_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @description_change_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
3 changes: 1 addition & 2 deletions app/views/fee_change_validation_requests/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :fee_change_validation_request,
url: fee_change_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @fee_change_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
3 changes: 1 addition & 2 deletions app/views/heads_of_term_validation_requests/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :heads_of_term_validation_request,
url: heads_of_term_validation_request_path(planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @heads_of_term_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
5 changes: 2 additions & 3 deletions app/views/land_owners/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

<p class="govuk-body-s govuk-!-margin-bottom-1">Planning application reference number</p>
<p class="govuk-body"><%= @planning_application["reference"] %></p>

<h3 class="govuk-heading-s">Details of owner</h3>
<%= form_for @land_owner,
url: planning_application_ownership_certificate_land_owners_path(@planning_application["id"], @ownership_certificate),
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
url: planning_application_ownership_certificate_land_owners_path(@planning_application["id"], @ownership_certificate) do |form| %>
<%= form.govuk_text_field :name, label: { text: "Owner name" } %>
<%= form.govuk_text_field :address_1, label: { text: "Address line 1" } %>
<%= form.govuk_text_field :address_2, label: { text: "Address line 2 (optional)" } %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/neighbour_responses/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<%= form_for @new_response,
url: planning_application_neighbour_responses_path(@planning_application["id"]),
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
url: planning_application_neighbour_responses_path(@planning_application["id"]) do |form| %>
<%= hidden_field_tag :stage, @new_response.stage %>
<%= render @new_response.stage, form: form, response: form.object %>
<% end %>
3 changes: 1 addition & 2 deletions app/views/other_change_validation_requests/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :other_change_validation_request,
url: other_change_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @other_change_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :ownership_certificate_validation_request,
url: ownership_certificate_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @ownership_certificate_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
1 change: 0 additions & 1 deletion app/views/ownership_certificates/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<%= form_for @ownership_certificate,
url: planning_application_ownership_certificate_path(@planning_application["id"], @ownership_certificate),
builder: GOVUKDesignSystemFormBuilder::FormBuilder,
method: :patch do |form| %>
<%= form.govuk_radio_buttons_fieldset(:know_owners, legend: { size: 'm', text: 'Do you know how many owners there are?' }) do %>
<%= form.govuk_radio_button :know_owners, 'Yes', label: { text: 'Yes' } do %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/ownership_certificates/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<h1 class="govuk-heading-l">Confirm ownership</h1>

<%= form_for @ownership_certificate,
url: planning_application_ownership_certificates_path(@planning_application["id"]),
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
url: planning_application_ownership_certificates_path(@planning_application["id"]) do |form| %>
<%= form.govuk_radio_buttons_fieldset(:know_owners, legend: { size: 'm', text: 'Do you know how many owners there are?' }) do %>
<%= form.govuk_radio_button :know_owners, 'Yes', label: { text: 'Yes' } do %>
<%= form.govuk_text_field :number_of_owners, label: { text: 'Enter number of owners' } %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :pre_commencement_condition_validation_request,
url: pre_commencement_condition_validation_request_path(planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @pre_commencement_condition_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :red_line_boundary_change_validation_request,
url: red_line_boundary_change_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @red_line_boundary_change_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with scope: :red_line_boundary_change_validation_requests, url: red_line_boundary_change_validation_requests_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
<%= form_with scope: :red_line_boundary_change_validation_requests, url: red_line_boundary_change_validation_requests_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]), method: :patch do |form| %>
<% if flash["error"].present? %>
<span id="status-error" class="govuk-error-message">
<%= flash["error"] %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

<%= form_with scope: :replacement_document_validation_request,
url: replacement_document_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @replacement_document_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
3 changes: 1 addition & 2 deletions app/views/time_extension_validation_requests/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<%= form_with scope: :time_extension_validation_request,
url: time_extension_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]),
method: :patch,
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
method: :patch do |form| %>
<% if @time_extension_validation_request.errors.any? %>
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
Expand Down
9 changes: 9 additions & 0 deletions config/initializers/govuk_design_system_formbuilder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "govuk_design_system_formbuilder"

GOVUKDesignSystemFormBuilder.configure do |conf|
Rails.application.config.to_prepare do
ActionView::Base.default_form_builder = GOVUKDesignSystemFormBuilder::FormBuilder
end
end

0 comments on commit 1b7fb2a

Please sign in to comment.