Dynamic Nested Forms with Stimulus JS Discussion
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?
Hi Chris!
Just wanted to drop a line - GoRails is the best Rails content on the web! Thank you!
@chris how can I add custom fields ? example I want Radio button , checkbox , text area all need in one form
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 -%>
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"
.
More stimulus please, this was so helpful in seeing how it works within the context of a rails. Thanks for this!