I’ld like to have a form, which can change with the input.
A short example:
A reservation is to be created. To do this, the user fills out the business event (for example, using select). Now the selected event must be sent to the server, so that the server determines the possible event-categories and offers them for further selection. Now the category is selected, which determines the maximum bookable tickets and the price per ticket. Finally, the number of tickets is selected and the price is calculated.
With Save the form is sent to the server.
I use Rails 6 with stimulus for simple dynamic form modifications (e.g. add or delete embedded fields is working meanwhile).
Now I’ld like to call the controller#new or controller#edit method again and again with the updated fields so that the whole form is server generated and refreshed. I prefer to compose the form server-side to have a single point of logic and/or validation. Stimulus should be only a smart frontend helper, transmitting the meanwhile filled fields to server and refreshing the form. It should act like a wizard, but without multipage…
Is there an example for this? I currently can’t get it to work, because I am a newbie.
Or is there a better way to do something like this?
Thank you for your help