mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Display errors on checkout State field
This commit is contained in:
@@ -36,7 +36,18 @@ module CheckoutHelper
|
||||
"ng-class" => "{error: !fieldValid('#{path}')}"
|
||||
}.merge args
|
||||
|
||||
render partial: "shared/validated_input", locals: {name: name, path: path, attributes: attributes}
|
||||
render "shared/validated_input", name: name, path: path, attributes: attributes
|
||||
end
|
||||
|
||||
def validated_select(name, path, options, args = {})
|
||||
attributes = {
|
||||
required: true,
|
||||
id: path,
|
||||
"ng-model" => path,
|
||||
"ng-class" => "{error: !fieldValid('#{path}')}"
|
||||
}.merge args
|
||||
|
||||
render "shared/validated_select", name: name, path: path, options: options, attributes: attributes
|
||||
end
|
||||
|
||||
def reset_order
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
= validated_input "City", "order.bill_address.city"
|
||||
|
||||
.small-6.columns
|
||||
= ba.select :state_id, @order.billing_address.country.states.map{|c|[c.name, c.id]}, {include_blank: false},
|
||||
"ng-model" => "order.bill_address.state_id", required: true
|
||||
= validated_select "State", "order.bill_address.state_id", [[]]+@order.billing_address.country.states.map{|c|[c.name, c.id]}
|
||||
.row
|
||||
.small-6.columns
|
||||
= validated_input "Postcode", "order.bill_address.zipcode"
|
||||
|
||||
6
app/views/shared/_validated_select.html.haml
Normal file
6
app/views/shared/_validated_select.html.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
%label{for: path}= name
|
||||
|
||||
= select_tag path, options_for_select(options), attributes
|
||||
|
||||
%small.error.medium.input-text{"ng-show" => "!fieldValid('#{path}')"}
|
||||
= "{{ fieldErrors('#{path}') }}"
|
||||
Reference in New Issue
Block a user