Module: PicoPhone::Rails::FormHelper
- Defined in:
- lib/pico_phone/rails/form_helper.rb
Overview
Included into ActionView::Base by the railtie once ActionView loads.
Adds pico_phone_field_tag, a +text_field_tag+-like helper that
displays national format for a valid number while leaving the
underlying <input> free to submit whatever string the user types.
Named distinctly from Rails' own +phone_field_tag+/+f.phone_field+
(a built-in alias for telephone_field, plain <input type="tel">
with no formatting) rather than overriding it -- redefining a core
Rails helper would silently change behavior for every phone_field
call in an app, not just ones backed by a PicoPhone-managed attribute.
Instance Method Summary collapse
-
#pico_phone_field_tag(name, value = nil, region: nil, **options) ⇒ String
An HTML-safe
<input type="tel">tag.
Instance Method Details
#pico_phone_field_tag(name, value = nil, region: nil, **options) ⇒ String
Returns an HTML-safe <input type="tel"> tag.
43 44 45 46 |
# File 'lib/pico_phone/rails/form_helper.rb', line 43 def pico_phone_field_tag(name, value = nil, region: nil, **) display_value = PicoPhone::Rails.phone_field_display_value(value, region) text_field_tag(name, display_value, .merge(type: "tel")) end |