Class: NameInput
- Inherits:
-
SimpleForm::Inputs::TextInput
- Object
- SimpleForm::Inputs::TextInput
- NameInput
- Defined in:
- app/inputs/name_input.rb
Overview
A text field that is used for the Name fields of content.
Add the following behaviors above and beyond
1. Will generate a slug if the class requires it. (Requires a as: :path field to work)
2. If no label is specified, it shows a larger than normal input which spans the full row.
3. Labels are turned off by default.
Instance Method Summary collapse
-
#initialize(*args) ⇒ NameInput
constructor
A new instance of NameInput.
- #input(_wrapper_options = nil) ⇒ Object
Constructor Details
#initialize(*args) ⇒ NameInput
Returns a new instance of NameInput.
11 12 13 14 15 |
# File 'app/inputs/name_input.rb', line 11 def initialize(*args) super(*args) [:label] = false if [:label].nil? [:placeholder] = "Name" if [:placeholder].nil? end |
Instance Method Details
#input(_wrapper_options = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/inputs/name_input.rb', line 17 def input( = nil) add_slug_source_for_content_that_needs_it unless [:label] [:class] << 'input-block-level input-xxlarge' end @builder.text_field(attribute_name, ).html_safe end |