# Reactive Fields

Create smart forms where fields update based on user input.

- Price: $40/month
- Gem: `gem "avo-reactive_fields"`
- Web page: https://avohq.io/addons/reactive-fields
- Pricing: https://avohq.io/pricing.md

Let one field respond to another as your users type. Reactive Fields adds a `react_on` option to any Avo field, so a city select can repopulate when the country changes, a slug can fill itself from a name, and a price can recompute the moment a quantity is edited, all on the same form. It's all plain Ruby, no JavaScript to write and no Stimulus controller to wire up.

When a watched field changes, the form posts itself back over Turbo and Avo re-renders only the reacting fields. Point a field at one dependency, a list, or every field on the form with `react_on: :all`, then derive its value with a `format_using` or `options` lambda that reads the current `@record`. Dependent forms like that are fiddly to wire and easy to break on the next Avo upgrade. Here the wiring is already built and vetted, and it moves with Avo instead of drifting.

## What you get

- Wire a dependent form in one line: add `react_on` to any field, point it at one field, a list, or `:all`, and skip the Stimulus controller
- Cascading selects that stay in sync: a city dropdown that repopulates the moment the country changes, no stale options
- Fields that fill themselves: derive a slug, a total, or a price with a `format_using` lambda the instant its source changes
- Your lambdas always see the form as the user left it, `@record` carries the latest values on every update, so derived values are never one edit behind
- Compare against what changed: original values stay available through Rails' `*_was` methods
- Reacts on the right event for you, selects and checkboxes on change, text inputs on debounced input, so it feels instant without firing on every keystroke

## Why it pays off

- Ship a dependent form this afternoon with one `react_on` line, instead of generating and re-reviewing Stimulus and Turbo wiring in every app.
- Reactive forms are easy to get subtly wrong: stale `@record` state, options that do not refresh, fields that fire on the wrong event. Those cases are already covered, vetted across hundreds of apps.
- Every Avo release makes it better: the reactive behavior gains improvements and the field options you rely on keep working through upgrades, and fixes reach your app with bundle update.
- Tokens, time, and focus go to the form logic, not to front-end plumbing generated from scratch.

## Questions

### How do I build a dependent select in Rails without JavaScript?

Add `react_on` to the dependent field. A city select with `react_on: :country` and an `options` block that reads `@record.country` gets a fresh list whenever the country changes. Avo posts the form back over Turbo and re-renders only the fields that react, so there's no Stimulus controller to write.

Included in bundles: Growth ($145/month)

## Recent releases

- 1.0.0
