All you need to know to build Dynamic Forms (JS FREE)
summary
Shows a concrete Rails implementation that renders DB-driven forms, validates and persists submissions (creates a Reference record), and supports repeatable fields without bespoke JS. Uses ActiveModel API on plain Ruby objects plus the Form Objects pattern to run validations and a save method, and swaps a fragile custom JS approach for Hotwire turbo streams to append/remove field fragments. Includes a small gem (yes) mention, uses SecureRandom UUIDs for transient repetitions, and it works in production.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 2:33Context
- 4:38Modelling the solution
- 6:32Lifecycle of a form
- 8:32Rendering the Dynamic Form
- 11:16ActiveModel API
- 14:05Using ActiveModel in a PORO
- 16:23Adding validations
- 17:17Submitting the form
- 18:29Form Objects Pattern
- 20:23Implementing save and save!
- 22:07Final boss: Repeatable fields
- 27:03Using Hotwire
related talks
33mOld-school Javascript in Rails
27mDecouple Your Models with Form Objects
34mYour Front End Framework is Overkill - Server Side Javascript w/ Rails
42mPowerful Rails Features You Might Not Know
21m6 degrees of JavaScript on Rails
26mDon't Rewrite Your Framework
37mDungeons & Dragons & Rails
22mBryan's ActieModel Extravaganza
