Skip to content

Commit

Permalink
Merge pull request #2896 from DFE-Digital/minor-form-tweaks-13
Browse files Browse the repository at this point in the history
[CAPT-1729] Use GOVUK formbuilder for provide mobile form
  • Loading branch information
asmega authored Jun 24, 2024
2 parents 6d78e2a + 14fd732 commit d5aa992
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 37 deletions.
7 changes: 7 additions & 0 deletions app/forms/provide_mobile_number_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def save
journey_session.save!
end

def radio_options
[
OpenStruct.new(id: true, name: "Yes"),
OpenStruct.new(id: false, name: "No")
]
end

private

def provide_mobile_number_changed?
Expand Down
55 changes: 18 additions & 37 deletions app/views/claims/provide_mobile_number.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,24 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render("shared/error_summary", instance: @form, errored_field_id_overrides: { provide_mobile_number: "claim_provide_mobile_number_true" }) if @form.errors.any? %>

<%= form_for @form, url: claim_path(current_journey_routing_name) do |form| %>
<span class="govuk-caption-xl"><%= t("questions.personal_details") %></span>

<%= form_group_tag @form do %>
<%= form.hidden_field :provide_mobile_number %>

<fieldset class="govuk-fieldset" aria-describedby="provide-mobile-number-hint">
<legend class="govuk-fieldset__legend <%= fieldset_legend_css_class_for_journey(journey) %>">
<h1 class="govuk-fieldset__heading">
<%= t("questions.provide_mobile_number") %>
</h1>
</legend>

<div class="govuk-hint" id="provide-mobile-number-hint">
We will only use this number if we are unable to contact you via email. It may slow
down your application if we are unable to reach you.
</div>

<%= errors_tag @form, :provide_mobile_number %>

<div class="govuk-radios">
<div class="govuk-radios__item">
<%= form.radio_button(:provide_mobile_number, true, class: "govuk-radios__input") %>
<%= form.label :provide_mobile_number_true, "Yes", class: "govuk-label govuk-radios__label" %>
</div>

<div class="govuk-radios__item">
<%= form.radio_button(:provide_mobile_number, false, class: "govuk-radios__input") %>
<%= form.label :provide_mobile_number_false, "No", class: "govuk-label govuk-radios__label" %>
</div>
</div>
</fieldset>
<% end %>

<%= form.submit "Continue", class: "govuk-button", data: {module: "govuk-button"} %>
<%= form_with model: @form, url: claim_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_collection_radio_buttons :provide_mobile_number, @form.radio_options, :id, :name,
caption: {
text: t("questions.personal_details"),
size: "xl"
},
legend: {
text: t("questions.provide_mobile_number"),
tag: "h1",
size: "l"
},
hint: {
text: "We will only use this number if we are unable to contact you via email. It may slow down your application if we are unable to reach you."
} %>

<%= f.govuk_submit "Continue" %>
<% end %>
</div>
</div>

0 comments on commit d5aa992

Please sign in to comment.