Class: ConstraintValidations::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- ConstraintValidations::FormBuilder
show all
- Includes:
- Extensions
- Defined in:
- lib/constraint_validations/form_builder.rb,
lib/constraint_validations/form_builder/extensions.rb
Defined Under Namespace
Modules: Extensions
Class Method Summary
collapse
Methods included from Extensions
#errors, #initialize, #validation_message, #validation_message_id, #validation_message_template
Class Method Details
.errors(object, field, &block) ⇒ Object
13
14
15
16
17
|
# File 'lib/constraint_validations/form_builder.rb', line 13
def self.errors(object, field, &block)
validation_messages = object.respond_to?(:errors) ? object.errors[field] : []
block ? yield(validation_messages) : validation_messages
end
|
.validation_message_id(template, object_or_name, method, **options) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/constraint_validations/form_builder.rb', line 5
def self.validation_message_id(template, object_or_name, method, **options)
if ::ActionView::VERSION::MAJOR < 7
template = BackPorts.new(template)
end
template.field_id(object_or_name, method, :validation_message, **options)
end
|
.visible?(tag_builder) ⇒ Boolean
19
20
21
22
23
24
25
|
# File 'lib/constraint_validations/form_builder.rb', line 19
def self.visible?(tag_builder)
if tag_builder.class.respond_to?(:field_type)
tag_builder.class.field_type != "hidden"
else
true
end
end
|