Class: ViewComponent::Form::BaseComponent
- Inherits:
-
Object
- Object
- ViewComponent::Form::BaseComponent
- Includes:
- ClassNamesHelper
- 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
Methods included from ClassNamesHelper
#build_tag_values, #class_names
Constructor Details
#initialize(form, object_name, options = {}) ⇒ BaseComponent
Returns a new instance of BaseComponent.
16 17 18 19 20 21 22 23 24 |
# File 'app/components/view_component/form/base_component.rb', line 16 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.
12 13 14 |
# File 'app/components/view_component/form/base_component.rb', line 12 def form @form end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
12 13 14 |
# File 'app/components/view_component/form/base_component.rb', line 12 def object_name @object_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'app/components/view_component/form/base_component.rb', line 12 def @options end |
Instance Method Details
#html_class ⇒ Object
38 39 40 |
# File 'app/components/view_component/form/base_component.rb', line 38 def html_class nil end |
#object_errors ⇒ Object
32 33 34 35 36 |
# File 'app/components/view_component/form/base_component.rb', line 32 def object_errors return nil unless object object.errors end |
#object_errors? ⇒ Boolean
26 27 28 29 30 |
# File 'app/components/view_component/form/base_component.rb', line 26 def object_errors? return false unless object object.errors.any? end |