Last active
November 7, 2019 15:35
-
-
Save peteryates/172fafb756f3cde6e344025dc935aa95 to your computer and use it in GitHub Desktop.
Form with acceptance validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_with(model: account, local: true) do |form| %> | |
<%= form.govuk_error_summary %> | |
<%= form.govuk_email_field(:email) %> | |
<%= form.govuk_check_boxes_fieldset :terms_and_conditions, | |
legend: { text: 'Please accept our terms and conditions' } do %> | |
<%= form.hidden_field :terms_and_conditions, value: false %> | |
<%= form.govuk_check_box :terms_and_conditions, true, multiple: false, link_errors: true %> | |
<% end %> | |
<%= form.govuk_submit %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account < ApplicationRecord | |
validates :email, presence: true | |
validates :terms_and_conditions, acceptance: { accept: true } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment