-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Given the following class hierarchy:
Superform::Rails::Component < ApplicationComponent
Superform::Rails::Form < Superform::Rails::Component
Superform::Rails::Form::Components::BaseComponent < Superform::Rails::Component
Superform::Rails::Form::Components::BaseComponent deviated its interface for attributes from the Superform::Rails::Component.
Where as Component assigns all remaining plat kwargs as attributes, in Components::BaseComponent it required the keyword :attributes.
superform/lib/superform/rails.rb
Line 206 in 122ca32
| def initialize(field, attributes: {}) |
Suggestion to keep components interface consistent across the board and change this in Components::BaseComponent:
class Components::BaseComponent
def initialize(field, **attributes)
@field = field
@attributes = attributes
end
class Superform::Rails::Field
def input(**attributes)
Components::InputComponent.new(self, **attributes)
endThis still allows you to pass attributes explicitly, should you want to:
def initialize(field, attributes: {})But allows us to use keywords as expected in other components.
To make attributes required or give them default values, yet open for additional html attributes:
def initialize(field, selected: false, value:, **attributes)
end