Class: ViewComponent::Form::BaseComponent
- Inherits:
-
Object
- Object
- ViewComponent::Form::BaseComponent
- Defined in:
- app/components/view_component/form/base_component.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.default_options ⇒ Object
Returns the value of attribute default_options.
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #html_class ⇒ Object
-
#initialize(form, object_name, options = {}) ⇒ BaseComponent
constructor
A new instance of BaseComponent.
- #object_errors ⇒ Object
- #object_errors? ⇒ Boolean
Constructor Details
#initialize(form, object_name, options = {}) ⇒ BaseComponent
Returns a new instance of BaseComponent.
14 15 16 17 18 19 20 21 22 |
# File 'app/components/view_component/form/base_component.rb', line 14 def initialize(form, object_name, = {}) @form = form # See: https://github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/actionview/lib/action_view/helpers/tags/base.rb#L13 @object_name = object_name.to_s.dup @options = super() end |
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
7 8 9 |
# File 'app/components/view_component/form/base_component.rb', line 7 def @default_options end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
10 11 12 |
# File 'app/components/view_component/form/base_component.rb', line 10 def form @form end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
10 11 12 |
# File 'app/components/view_component/form/base_component.rb', line 10 def object_name @object_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'app/components/view_component/form/base_component.rb', line 10 def @options end |
Instance Method Details
#html_class ⇒ Object
36 37 38 |
# File 'app/components/view_component/form/base_component.rb', line 36 def html_class nil end |
#object_errors ⇒ Object
30 31 32 33 34 |
# File 'app/components/view_component/form/base_component.rb', line 30 def object_errors return nil unless object object.errors end |
#object_errors? ⇒ Boolean
24 25 26 27 28 |
# File 'app/components/view_component/form/base_component.rb', line 24 def object_errors? return false unless object object.errors.any? end |