Class: CaringForm::Field::Tel

Inherits:
Base
  • Object
show all
Defined in:
lib/caring_form/field/tel.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#default_label, #initialize, register, #render

Constructor Details

This class inherits a constructor from CaringForm::Field::Base

Instance Method Details

#apply_to_model(klass) ⇒ Object



12
13
14
15
16
# File 'lib/caring_form/field/tel.rb', line 12

def apply_to_model(klass)
  super
  klass.send(:validates_format_of, name, :allow_blank => true,
             :with => regexp, :message => message, :multiline => true)
end

#input_properties(form, options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/caring_form/field/tel.rb', line 18

def input_properties(form, options = {})
  super.tap do |req|
    req[:input_html][:pattern] ||= regexp.source
    req[:input_html][:title] ||= message
    req[:input_html][:type]  ||= 'tel'
  end
end

#simple_typeObject



8
9
10
# File 'lib/caring_form/field/tel.rb', line 8

def simple_type
  :string
end