Class: Shoelace::Rails::Ui::FormHelper::ShoelaceInputField
- Inherits:
-
ActionView::Helpers::Tags::TextField
- Object
- ActionView::Helpers::Tags::TextField
- Shoelace::Rails::Ui::FormHelper::ShoelaceInputField
- Defined in:
- app/helpers/shoelace/rails/ui/form_helper.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
Instance Method Summary collapse
-
#initialize(field_type, *args) ⇒ ShoelaceInputField
constructor
A new instance of ShoelaceInputField.
- #render(&block) ⇒ Object
Constructor Details
#initialize(field_type, *args) ⇒ ShoelaceInputField
Returns a new instance of ShoelaceInputField.
33 34 35 36 |
# File 'app/helpers/shoelace/rails/ui/form_helper.rb', line 33 def initialize(field_type, *args) super(*args) @field_type = field_type end |
Instance Attribute Details
#field_type ⇒ Object (readonly)
Returns the value of attribute field_type.
31 32 33 |
# File 'app/helpers/shoelace/rails/ui/form_helper.rb', line 31 def field_type @field_type end |
Instance Method Details
#render(&block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/shoelace/rails/ui/form_helper.rb', line 38 def render(&block) = @options.stringify_keys value = .fetch("value") { value_before_type_cast } ["value"] = value if value.present? ["size"] = ["maxlength"] unless .key?("size") ["type"] ||= field_type ["invalid"] = .fetch("invalid") { @object.errors[@method_name].presence } add_default_name_and_id() @template_object.content_tag('sl-input', '', , &block) end |