Skip to content

Commit

Permalink
Merge branch 'master' of github.com:DavyJonesLocker/client_side_valid…
Browse files Browse the repository at this point in the history
…ations

* 'master' of github.com:DavyJonesLocker/client_side_validations:
  Fix file_field helper
  • Loading branch information
tagliala committed Feb 6, 2017
2 parents bddc0c0 + 53b5766 commit 60605f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/client_side_validations/action_view/form_builder.rb
Expand Up @@ -3,7 +3,7 @@ module ActionView
module Helpers
module FormBuilder
def self.prepended(base)
(base.field_helpers.map(&:to_s) - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector|
(base.field_helpers - %i(label check_box radio_button fields_for hidden_field file_field)).each do |selector|
base.class_eval <<-RUBY_EVAL
def #{selector}(method, options = {})
build_validation_options(method, options)
Expand Down Expand Up @@ -90,6 +90,12 @@ def time_zone_select(method, priority_zones = nil, options = {}, html_options =
super(method, priority_zones, options, html_options)
end

def file_field(method, options = {})
build_validation_options(method, options)
options.delete(:validate)
super(method, options)
end

private

def build_validation_options(method, options = {})
Expand Down
2 changes: 1 addition & 1 deletion test/action_view/cases/test_helpers.rb
Expand Up @@ -42,7 +42,7 @@ def test_password_field
end

def test_file_field
form_for(@post, validate: true, html: { multipart: true }) do |f|
form_for(@post, validate: true) do |f|
concat f.file_field(:cost)
end

Expand Down
2 changes: 1 addition & 1 deletion test/action_view/cases/test_legacy_helpers.rb
Expand Up @@ -27,7 +27,7 @@ def test_password_field
end

def test_file_field
form_for(@post, html: { multipart: true }) do |f|
form_for(@post) do |f|
concat f.file_field(:cost)
end

Expand Down

0 comments on commit 60605f6

Please sign in to comment.