Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Defined in:
- lib/optimism.rb
Instance Method Summary collapse
- #container_for(attribute, **options, &block) ⇒ Object
- #container_id_for(attribute) ⇒ Object
- #error_for(attribute, **options) ⇒ Object
- #error_id_for(attribute) ⇒ Object
Instance Method Details
#container_for(attribute, **options, &block) ⇒ Object
97 98 99 |
# File 'lib/optimism.rb', line 97 def container_for(attribute, **, &block) @template.tag.div @template.capture(&block), .merge!(id: container_id_for(attribute)) if block_given? end |
#container_id_for(attribute) ⇒ Object
101 102 103 |
# File 'lib/optimism.rb', line 101 def container_id_for(attribute) Optimism.container_selector.sub("RESOURCE", object_name.to_s.delete("]").tr("[", "_")).sub("ATTRIBUTE", attribute.to_s)[1..-1] end |
#error_for(attribute, **options) ⇒ Object
105 106 107 |
# File 'lib/optimism.rb', line 105 def error_for(attribute, **) @template.tag.span .merge! id: error_id_for(attribute) end |
#error_id_for(attribute) ⇒ Object
109 110 111 |
# File 'lib/optimism.rb', line 109 def error_id_for(attribute) Optimism.error_selector.sub("RESOURCE", object_name.to_s.delete("]").tr("[", "_")).sub("ATTRIBUTE", attribute.to_s)[1..-1] end |