Class: Railsboot::FormField::ValidationComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::FormField::ValidationComponent
- Defined in:
- app/components/railsboot/form_field/validation_component.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(valid: false, tag: "div", **html_attributes) ⇒ ValidationComponent
constructor
A new instance of ValidationComponent.
- #render? ⇒ Boolean
Constructor Details
#initialize(valid: false, tag: "div", **html_attributes) ⇒ ValidationComponent
Returns a new instance of ValidationComponent.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'app/components/railsboot/form_field/validation_component.rb', line 2 def initialize(valid: false, tag: "div", **html_attributes) @valid = valid @tag = tag @html_attributes = html_attributes @html_attributes[:class] = class_names( @valid ? "text-success" : "text-danger", "mt-1", html_attributes[:class] ) end |
Instance Method Details
#call ⇒ Object
14 15 16 |
# File 'app/components/railsboot/form_field/validation_component.rb', line 14 def call render(Railsboot::BaseComponent.new(tag: @tag, **@html_attributes)) { content } end |
#render? ⇒ Boolean
18 19 20 |
# File 'app/components/railsboot/form_field/validation_component.rb', line 18 def render? content? end |