Module: ClientSideValidations::ActionView::Helpers::FormBuilder
- Defined in:
- lib/client_side_validations/action_view/form_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_box_with_client_side_validations(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #collection_select_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
- #fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) ⇒ Object
- #grouped_collection_select_with_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
- #initialize_with_client_side_validations(object_name, object, template, options, proc) ⇒ Object
- #radio_button_with_client_side_validations(method, tag_value, options = {}) ⇒ Object
- #select_with_client_side_validations(method, choices, options = {}, html_options = {}) ⇒ Object
- #time_zone_select_with_client_side_validations(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 4 def self.included(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.class_eval <<-RUBY_EVAL def #{selector}_with_client_side_validations(method, options = {}) apply_client_side_validators(method, options) options.delete(:validate) #{selector}_without_client_side_validations(method, options) end RUBY_EVAL base.class_eval { alias_method_chain selector, :client_side_validations } end base.class_eval do alias_method_chain :initialize, :client_side_validations alias_method_chain :fields_for, :client_side_validations alias_method_chain :check_box, :client_side_validations alias_method_chain :radio_button, :client_side_validations alias_method_chain :select, :client_side_validations alias_method_chain :collection_select, :client_side_validations alias_method_chain :grouped_collection_select, :client_side_validations alias_method_chain :time_zone_select, :client_side_validations def self.client_side_form_settings(, form_helper) { :type => self.to_s, :input_tag => form_helper.class.field_error_proc.call(%{<span id="input_tag" />}, Struct.new(:error_message, :tag_id).new([], "")), :label_tag => form_helper.class.field_error_proc.call(%{<label id="label_tag" />}, Struct.new(:error_message, :tag_id).new([], "")) } end end end |
Instance Method Details
#check_box_with_client_side_validations(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
48 49 50 51 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 48 def check_box_with_client_side_validations(method, = {}, checked_value = "1", unchecked_value = "0") apply_client_side_validators(method, ) check_box_without_client_side_validations(method, , checked_value, unchecked_value) end |
#collection_select_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
63 64 65 66 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 63 def collection_select_with_client_side_validations(method, collection, value_method, text_method, = {}, = {}) apply_client_side_validators(method, ) collection_select_without_client_side_validations(method, collection, value_method, text_method, , ) end |
#fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) ⇒ Object
42 43 44 45 46 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 42 def fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) = args. [:validate] ||= @options[:validate] if @options[:validate] && !.key?(:validate) fields_for_without_client_side_validations(record_or_name_or_array, *(args << ), &block) end |
#grouped_collection_select_with_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
68 69 70 71 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 68 def grouped_collection_select_with_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, = {}, = {}) apply_client_side_validators(method, ) grouped_collection_select_without_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, , ) end |
#initialize_with_client_side_validations(object_name, object, template, options, proc) ⇒ Object
37 38 39 40 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 37 def initialize_with_client_side_validations(object_name, object, template, , proc) initialize_without_client_side_validations(object_name, object, template, , proc) @options[:validators] = {} end |
#radio_button_with_client_side_validations(method, tag_value, options = {}) ⇒ Object
53 54 55 56 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 53 def (method, tag_value, = {}) apply_client_side_validators(method, ) (method, tag_value, ) end |
#select_with_client_side_validations(method, choices, options = {}, html_options = {}) ⇒ Object
58 59 60 61 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 58 def select_with_client_side_validations(method, choices, = {}, = {}) apply_client_side_validators(method, ) select_without_client_side_validations(method, choices, , ) end |
#time_zone_select_with_client_side_validations(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
73 74 75 76 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 73 def time_zone_select_with_client_side_validations(method, priority_zones = nil, = {}, = {}) apply_client_side_validators(method, ) time_zone_select_without_client_side_validations(method, priority_zones = nil, , ) end |