-
Notifications
You must be signed in to change notification settings - Fork 21
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
Expand one empty collection item fields in the form without click on Add button #20
Comments
Are you asking about a JS function, or the way to add item it in backend? |
Making them on the backend would be better I think but ideally I'd like to have both options. |
Backend You must add a new items to your struct with additional If you are using Ecto, then you have to preload that association before adding new items. Example with Ecto: article = Repo.get!(Article, id)
|> Repo.preload(:comments)
article = Map.put(article, :comments, article.comments ++ [
%App.Comment{
content: "default content of a new comment", # optional
formex_id: "1" # required. it may be any unique string
},
%App.Comment{
content: "default content of yet another new comment",
formex_id: "2"
}
])
form = create_form(App.ArticleType, article) JS import { Collection } from 'formex'
Collection.addCollectionItemForm($('.formex-collection')) Sorry for the jQuery dependency 😄 |
Thanks, I'll try it out... |
What is the way to make one group of fields for adding new collection item to show up without need to click on the Add button?
The text was updated successfully, but these errors were encountered: