Class: Shoelace::Components::SlInput
- Inherits:
-
ActionView::Helpers::Tags::TextField
- Object
- ActionView::Helpers::Tags::TextField
- Shoelace::Components::SlInput
- Includes:
- ErrorWrappable
- Defined in:
- app/helpers/shoelace/components/sl_input.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) ⇒ SlInput
constructor
A new instance of SlInput.
- #render(&block) ⇒ Object
Methods included from ErrorWrappable
Constructor Details
#initialize(field_type, *args) ⇒ SlInput
Returns a new instance of SlInput.
12 13 14 15 |
# File 'app/helpers/shoelace/components/sl_input.rb', line 12 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.
10 11 12 |
# File 'app/helpers/shoelace/components/sl_input.rb', line 10 def field_type @field_type end |
Instance Method Details
#render(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/shoelace/components/sl_input.rb', line 17 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"] = ["data-invalid"] = "" if object_has_errors? add_default_name_and_id() @template_object.content_tag('sl-input', '', , &block) end |