Module: WhittakerTech::Midas::FormHelper
- Defined in:
- app/helpers/whittaker_tech/midas/form_helper.rb
Overview
Form helper for rendering currency input fields with bank-style typing behavior.
This helper provides a headless currency input that the parent application can style according to its design system. The helper only provides the behavior (via Stimulus) and basic structure.
Instance Method Summary collapse
-
#midas_currency_field(form, attribute, currency_code:, **options) ⇒ String
Renders a currency input field with bank-style typing behavior.
Instance Method Details
#midas_currency_field(form, attribute, currency_code:, **options) ⇒ String
Renders a currency input field with bank-style typing behavior.
The field consists of:
- A visible formatted input (displays dollars/euros)
- A hidden input storing minor units (cents)
- A hidden input storing the currency code
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/whittaker_tech/midas/form_helper.rb', line 51 def midas_currency_field(form, attribute, currency_code:, **) input_html = .fetch(:input_html, {}) wrapper_html = .fetch(:wrapper_html, {}) decimals = .fetch(:decimals, 2) label_text = .fetch(:label, nil) # Get current value if coin exists resource = form.object coin = resource.public_send(attribute) if resource.respond_to?(attribute) current_minor = coin&.currency_minor || 0 render partial: 'whittaker_tech/midas/shared/currency_field', locals: { form: form, attribute: attribute, currency_code: currency_code, current_minor: current_minor, decimals: decimals, input_html: input_html, wrapper_html: wrapper_html, label_text: label_text } end |