Ask A Question

Notifications

You’re not receiving notifications from this thread.

Dynamic Nested Forms with Stimulus JS Discussion

Very Informative and simple way.

Reply

That was fantastic. Thank you so much. I was pulling my hear out trying to make this work but this was a snap. One question Ihave is how would yu emplement this a second time within the same form?

Reply

Hi Chris!
Just wanted to drop a line - GoRails is the best Rails content on the web! Thank you!

Reply

@chris how can I add custom fields ? example I want Radio button , checkbox , text area all need in one form

Reply

I had issue to delete a persisted task on rails 6. I could make it work by adding a hidden_field to pass the :id of the task to delete. I don't know if it was the unique reason of my problem but if it can help :

<%- unless form.object.new_record? -%>
<%= form.hidden_field :id -%>
<%- end -%>

Reply

I would love to see an updated version of this for Hotwire!

Reply

Thanks Chris, still very much relevant in mid 2022.

A couple things seem outdated as long as Stimulus syntax goes, but other than that all good!

For example data-target="nested-form.links" would need to be data-nested-form-target="links".

Reply

More stimulus please, this was so helpful in seeing how it works within the context of a rails. Thanks for this!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.