Display errors on checkout State field

This commit is contained in:
Rohan Mitchell
2014-11-06 14:33:35 +11:00
parent e50d2a6a37
commit 900a98b4bb
3 changed files with 19 additions and 3 deletions

View File

@@ -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

View File

@@ -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"

View 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}') }}"