Class: Formtastic::Inputs::TokenInput
- Inherits:
-
Object
- Object
- Formtastic::Inputs::TokenInput
- Includes:
- Base
- Defined in:
- lib/formtastic/inputs/token_input.rb
Instance Method Summary collapse
- #input_html_options ⇒ Object
- #name_method ⇒ Object
- #name_value ⇒ Object
- #prepopulated_value ⇒ Object
- #record ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#input_html_options ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/formtastic/inputs/token_input.rb', line 13 def super.merge({ :required => nil, :autofocus => nil, :class => 'token-input', 'data-model-name' => reflection.klass.model_name.singular }).tap do || if record.present? ["data-pre"] = prepopulated_value.to_json end end end |
#name_method ⇒ Object
30 31 32 |
# File 'lib/formtastic/inputs/token_input.rb', line 30 def name_method builder.collection_label_methods.find { |m| record.respond_to?(m) } end |
#name_value ⇒ Object
34 35 36 |
# File 'lib/formtastic/inputs/token_input.rb', line 34 def name_value record.send(name_method) end |
#prepopulated_value ⇒ Object
26 27 28 |
# File 'lib/formtastic/inputs/token_input.rb', line 26 def prepopulated_value [{"value" => name_value, "id" => record.id}] end |
#record ⇒ Object
38 39 40 |
# File 'lib/formtastic/inputs/token_input.rb', line 38 def record @object.send(method) end |
#to_html ⇒ Object
6 7 8 9 10 11 |
# File 'lib/formtastic/inputs/token_input.rb', line 6 def to_html input_wrapping do label_html << builder.hidden_field(input_name, ) end end |