Closed Floppy closed 3 years ago
Well, yes this is already possible, but it requires some code of course.
Step 2 (adding an empty item) has been asked and answered many times, so we added it to our wiki
Secondly: "automatically adds another item" is hard to solve in a generic way (as being a part of cocoon imho), since it depends on how/when/which event you want to trigger the insertion of the new child form. But imho cocoon already has the required parts of solution. So in my idea a possible solution would look like this:
link_to_add_association
(the link contains the nested partial view to be inserted)Does this sound reasonable?
If you need more practical example, with more code, it would help to already show more of your own code to start from.
Ah, thanks, I'd not seen the wiki page, sorry. I'll see what I can work out based on your suggestions and add to the docs if I come up with anything that might be useful.
This is a great gem, thank you! A request though: currently the user must click a link to add the field before filling it in. Could cocoon be configured to automatically create an empty field when there are none available, saving that click?
Can this already be done and I've just missed it? Or would this be a useful feature?