Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamically adding form fields #31

Open
JohnRDOrazio opened this issue Jul 5, 2021 · 2 comments
Open

dynamically adding form fields #31

JohnRDOrazio opened this issue Jul 5, 2021 · 2 comments
Assignees

Comments

@JohnRDOrazio
Copy link
Collaborator

In PR #24 I included an example of dynamically adding form fields in a project, for the wedding party members.

However, we don't have the WeddingPartyMembers model just yet, so this is really just illustrative. The field names and ids are pretty much invented, and don't get posted to any kind of model.

Once we have our model in place, I'm guessing we should use some erb templating to generate the base row which can then be cloned, kind of like in this example.

@JohnRDOrazio
Copy link
Collaborator Author

Well we now have our model in place, and with PR #99 we also have some dynamic adding / removing of Wedding Party Members.

However we perhaps need to think this through better. Currently, with PR #99 , Wedding Party Members that don't yet exist in a project can be dynamically added or removed from a project. However, already existing Wedding Party Members can't be removed.

Currently, with PR #99, Wedding Party Members are added dynamically be manually templating the HTML structure in the Javascript file, so as to reflect the HTML structure produced by the Rails form builder. Could this manual templating be perhaps automated, using something like the nested form gem? And perhaps this gem would allow to remove already existing Wedding Party Members by marking them for removal.

@JohnRDOrazio
Copy link
Collaborator Author

Perhaps another useful gem, which seems to have better support and has been updated more recently, is the cocoon gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant