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
- #fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) ⇒ Object
- #initialize_with_client_side_validations(object_name, object, template, options, proc) ⇒ Object
- #radio_button_with_client_side_validations(method, tag_value, 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 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 4 def self.included(base) (base.field_helpers - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector| base.class_eval " def \#{selector}_with_client_side_validations(method, options = {})\n apply_client_side_validators(method, options)\n options.delete(:validate)\n \#{selector}_without_client_side_validations(method, options)\n end\n RUBY_EVAL\n\n base.class_eval { alias_method_chain selector, :client_side_validations }\n end\n\n base.class_eval do\n alias_method_chain :initialize, :client_side_validations\n alias_method_chain :fields_for, :client_side_validations\n alias_method_chain :check_box, :client_side_validations\n alias_method_chain :radio_button, :client_side_validations\n\n def self.client_side_form_settings(options, form_helper)\n {\n :type => self.to_s,\n :input_tag => form_helper.class.field_error_proc.call(%{<span id=\"input_tag\" />}, Struct.new(:error_message, :tag_id).new([], \"\")),\n :label_tag => form_helper.class.field_error_proc.call(%{<label id=\"label_tag\" />})\n }\n end\n end\nend\n" |
Instance Method Details
#check_box_with_client_side_validations(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
44 45 46 47 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 44 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 |
#fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) ⇒ Object
38 39 40 41 42 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 38 def fields_for_with_client_side_validations(record_or_name_or_array, *args, &block) = args. [:validate] ||= [:validate] if [:validate] && !.key?(:validate) fields_for_without_client_side_validations(record_or_name_or_array, *(args << ), &block) end |
#initialize_with_client_side_validations(object_name, object, template, options, proc) ⇒ Object
33 34 35 36 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 33 def initialize_with_client_side_validations(object_name, object, template, , proc) initialize_without_client_side_validations(object_name, object, template, , proc) [:validators] = {} end |
#radio_button_with_client_side_validations(method, tag_value, options = {}) ⇒ Object
49 50 51 52 |
# File 'lib/client_side_validations/action_view/form_builder.rb', line 49 def (method, tag_value, = {}) apply_client_side_validators(method, ) (method, tag_value, ) end |