Skip to content

feat(masked-input): add save_unmasked option to submit raw value#354

Open
karinevieira wants to merge 1 commit intoruby-ui:mainfrom
karinevieira:add_save_unmasked_to_masked_input
Open

feat(masked-input): add save_unmasked option to submit raw value#354
karinevieira wants to merge 1 commit intoruby-ui:mainfrom
karinevieira:add_save_unmasked_to_masked_input

Conversation

@karinevieira
Copy link
Copy Markdown
Contributor

Adds a save_unmasked option to MaskedInput that, when enabled, submits the raw (unformatted) value instead of the masked one.

Why

Previously, masked inputs would submit the formatted value to theserver (e.g., 1111 2222 instead of 11112222), requiring a custom Stimulus controller wrapper as a workaround. This brings the behavior natively into the component.

How

When save_unmasked: true is passed:

  • The visible input renders without a name attribute (so it's not submitted)
  • A hidden input with the original name is rendered as its next sibling
  • The Stimulus controller listens to the maska event and syncs event.detail.unmasked to the hidden input on every keystroke

Usage

MaskedInput(
  name: "iban",
  value: @record.iban,
  save_unmasked: true,
  data: { maska: "SSSS SSSS SSSS SSSS", maska_tokens: "S:[A-Z0-9]" }
)

@karinevieira karinevieira requested a review from cirdes as a code owner March 31, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant