Class: Proscenium::UI::Form::Fields::Tel
- Defined in:
- lib/proscenium/ui/form/fields/tel.rb
Constant Summary collapse
- DEFAULT_COUNTRY =
'US'
Instance Attribute Summary
Attributes inherited from Base
#attribute, #attributes, #form, #model
Instance Method Summary collapse
-
#initialize(attribute, model, form, type: nil, error: nil, **attributes) ⇒ Tel
constructor
A new instance of Tel.
- #view_template ⇒ Object
Constructor Details
#initialize(attribute, model, form, type: nil, error: nil, **attributes) ⇒ Tel
Returns a new instance of Tel.
14 15 16 17 18 |
# File 'lib/proscenium/ui/form/fields/tel.rb', line 14 def initialize(attribute, model, form, type: nil, error: nil, **attributes) super @default_country = @attributes.delete(:default_country)&.to_s&.upcase || DEFAULT_COUNTRY end |
Instance Method Details
#view_template ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/proscenium/ui/form/fields/tel.rb', line 20 def view_template field :pui_tel_field do label for: field_id div part: :inputs do div part: :country do select do countries.each do |name, code| option(value: code, selected: code == country) { name } end end end input(name: field_name, type: 'text', part: :number, id: field_id, **build_attributes) end hint end end |