Class: FieldableForm::TextField
- Defined in:
- lib/fieldable_form/text_field.rb
Constant Summary
Constants inherited from Field
Instance Method Summary collapse
- #max_length ⇒ Object
- #max_length=(value) ⇒ Object
- #min_length ⇒ Object
- #min_length=(value) ⇒ Object
- #number_only ⇒ Object
- #number_only=(value) ⇒ Object
-
#render_method ⇒ Object
Overrides.
-
#render_options ⇒ Object
Overrides.
- #required ⇒ Object
- #required=(value) ⇒ Object
-
#validators ⇒ Object
Overrides.
-
#view_partial_name ⇒ Object
Overrides.
Methods inherited from Field
Instance Method Details
#max_length ⇒ Object
64 65 66 |
# File 'lib/fieldable_form/text_field.rb', line 64 def max_length ['max_length'] end |
#max_length=(value) ⇒ Object
68 69 70 71 |
# File 'lib/fieldable_form/text_field.rb', line 68 def max_length=(value) if ['max_length'] != value ['max_length'] = value end |
#min_length ⇒ Object
55 56 57 |
# File 'lib/fieldable_form/text_field.rb', line 55 def min_length ['min_length'] end |
#min_length=(value) ⇒ Object
59 60 61 62 |
# File 'lib/fieldable_form/text_field.rb', line 59 def min_length=(value) if ['min_length'] != value ['min_length'] = value end |
#number_only ⇒ Object
46 47 48 |
# File 'lib/fieldable_form/text_field.rb', line 46 def number_only ['number_only'] end |
#number_only=(value) ⇒ Object
50 51 52 53 |
# File 'lib/fieldable_form/text_field.rb', line 50 def number_only=(value) if ['number_only'] != value ['number_only'] = value end |
#render_method ⇒ Object
Overrides
10 11 12 |
# File 'lib/fieldable_form/text_field.rb', line 10 def render_method :text_field end |
#render_options ⇒ Object
Overrides
15 16 17 |
# File 'lib/fieldable_form/text_field.rb', line 15 def [name] end |
#required ⇒ Object
37 38 39 |
# File 'lib/fieldable_form/text_field.rb', line 37 def required ['required'] end |
#required=(value) ⇒ Object
41 42 43 44 |
# File 'lib/fieldable_form/text_field.rb', line 41 def required=(value) if ['required'] != value ['required'] = value end |
#validators ⇒ Object
Overrides
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fieldable_form/text_field.rb', line 25 def validators min = integerize_or_nil(min_length) max = integerize_or_nil(max_length) validators = [] validators << ActiveModel::Validations::PresenceValidator.new(:attributes => name) if required == '1' validators << ActiveModel::Validations::NumericalityValidator.new(:attributes => name, :only_integer => true) if number_only == '1' validators << ActiveModel::Validations::LengthValidator.new(:attributes => name, :minimum => min ) if min validators << ActiveModel::Validations::LengthValidator.new(:attributes => name, :maximum => max ) if max validators end |
#view_partial_name ⇒ Object
Overrides
20 21 22 |
# File 'lib/fieldable_form/text_field.rb', line 20 def view_partial_name 'text_field' end |