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
rubocop:disable Metrics/ParameterLists.
- #view_template ⇒ Object
Methods inherited from Phlex
Methods included from Phlex::AssetInclusions
#include_assets, #include_javascripts, #include_stylesheets
Methods included from Phlex::CssModules
#after_template, #before_template, included, #process_attributes
Methods included from CssModule
Methods included from SourcePath
Constructor Details
#initialize(attribute, model, form, type: nil, error: nil, **attributes) ⇒ Tel
rubocop:disable Metrics/ParameterLists
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) # rubocop:disable Metrics/ParameterLists 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 |