Module: PicoPhone::Rails::FormBuilderExtension
- Defined in:
- lib/pico_phone/rails/form_helper.rb
Overview
Included into ActionView::Helpers::FormBuilder by the railtie once
ActionView loads. Adds f.pico_phone_field, mirroring
PicoPhone::Rails::FormHelper#pico_phone_field_tag but bound to the form's object.
Instance Method Summary collapse
-
#pico_phone_field(method, region: nil, live: false, **options) ⇒ String
An HTML-safe
<input type="tel">tag.
Instance Method Details
#pico_phone_field(method, region: nil, live: false, **options) ⇒ String
Returns an HTML-safe <input type="tel"> tag.
81 82 83 84 85 86 87 88 89 |
# File 'lib/pico_phone/rails/form_helper.rb', line 81 def pico_phone_field(method, region: nil, live: false, **) resolved_region = PicoPhone::Rails.resolve_region(region, object) display_value = PicoPhone::Rails.phone_field_display_value(object.public_send(method), resolved_region) if live data = PicoPhone::Rails.live_validation_data(resolved_region, @template.pico_phone_rails.validate_path) [:data] = data.merge([:data] || {}) end text_field(method, .merge(value: display_value, type: "tel")) end |