Class: NameInput

Inherits:
SimpleForm::Inputs::TextInput
  • Object
show all
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.

Examples:

<%= f.name as: :name %>

Instance Method Summary collapse

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)
  options[:label] = false if options[:label].nil?
  options[:placeholder] = "Name" if options[: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(_wrapper_options = nil)
  add_slug_source_for_content_that_needs_it

  unless options[:label]
    input_html_options[:class] << 'input-block-level input-xxlarge'
  end

  @builder.text_field(attribute_name, input_html_options).html_safe
end