Skip to content

Commit

Permalink
refactor: improve method name
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Jun 27, 2024
1 parent a100f0b commit 9e03e49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class SubjectsTaughtForm < Form

validates :subjects_taught,
presence: {message: i18n_error_message(:inclusion)},
inclusion: {in: ->(form) { form.radio_options.map(&:id) }, message: i18n_error_message(:inclusion)}
inclusion: {in: ->(form) { form.checkbox_options.map(&:id) }, message: i18n_error_message(:inclusion)}

def radio_options
def checkbox_options
[
OpenStruct.new(id: "building-and-construction", name: "Building and construction"),
OpenStruct.new(id: "chemistry", name: "Chemistry"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
hint: {
text: @form.t(:hint)
} do %>
<% @form.radio_options[0..-2].each do |option| %>
<%= f.govuk_check_box :subjects_taught, option.id, label: { text: option.name }, link_errors: @form.radio_options.first == option %>
<% @form.checkbox_options[0..-2].each do |option| %>
<%= f.govuk_check_box :subjects_taught, option.id, label: { text: option.name }, link_errors: @form.checkbox_options.first == option %>
<% end %>

<%= f.govuk_check_box_divider %>

<% option = @form.radio_options.last %>
<% option = @form.checkbox_options.last %>
<%= f.govuk_check_box :subjects_taught, option.id, label: { text: option.name }, exclusive: true %>
<% end %>

Expand Down

0 comments on commit 9e03e49

Please sign in to comment.