Browse Source

doing silly dance to get correct field highlighted on the error

pull/671/head
JG 3 years ago
parent
commit
4eda2a5dbf
  1. 2
      app/controllers/schemes_controller.rb
  2. 2
      app/models/scheme.rb
  3. 5
      config/locales/en.yml

2
app/controllers/schemes_controller.rb

@ -34,6 +34,8 @@ class SchemesController < ApplicationController
if @scheme.save
render "schemes/primary_client_group"
else
@scheme.errors.add(:organisation_id, message: @scheme.errors[:organisation])
@scheme.errors.delete(:organisation)
render :new, status: :unprocessable_entity
end
end

2
app/models/scheme.rb

@ -10,8 +10,6 @@ class Scheme < ApplicationRecord
scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") }
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(search_by_code(param)).distinct }
validates :organisation_id, presence: { message: I18n.t("validations.scheme.organisation_id_missing") }
SENSITIVE = {
No: 0,
Yes: 1,

5
config/locales/en.yml

@ -44,12 +44,9 @@ en:
scheme:
attributes:
organisation:
required: ""
required: "Enter the organisation’s name"
validations:
scheme:
organisation_id_missing: "Enter the organisation’s name"
organisation:
name_missing: "Enter the organisation’s name"
provider_type_missing: "Select the organisation’s type"

Loading…
Cancel
Save