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

Updating array field in collection #424

Open
maco144 opened this issue Oct 25, 2018 · 7 comments
Open

Updating array field in collection #424

maco144 opened this issue Oct 25, 2018 · 7 comments

Comments

@maco144
Copy link

maco144 commented Oct 25, 2018

I am wondering how I can make a field variable in collection into an array. I havent seen documentation or an example on how to.

"name": "rosters", "fields": [ { "name": "position", "title": "Position", "type": "array", "lookup_query_name": "stars", "input": "select", "lookup_field": "name", "lookup_key": "_id", "join_collection": "stars", "join_fields": ["name"], "join_container": "astar" }, { "name": "depth", "title": "Depth", "type": "integer", "min": 2 }

This creates the array of field position but I am unable to populate the field beyond the first array position in any update/insert form. I would like to set the size of the array to depth variable if possible. Help is greatly appreciated!

@maco144
Copy link
Author

maco144 commented Oct 26, 2018

I used this in the collection to add in empty data. The edit form from still doesnt show the position as multiple values just the first position in the array.

'
"after_insert_code":"
for(var i = 1; i <doc.roster_depth; i++) {
Rosters.update({ props_reference : doc._id}, { $push: {position: 'empty'}});
}"

@perak
Copy link
Owner

perak commented Oct 30, 2018

@maco144 you will get answer few hours after now.

@perak
Copy link
Owner

perak commented Oct 30, 2018

@maco144 Sorry, I don't fully understand:

  • What input control you want in the form? Checkbox or multi-select, or "tag" input or... ?

  • What is "depth" - is it number of items in the array, and if user don't choose "depth" number of items, remaining items should be populated with string "empty"?

@maco144
Copy link
Author

maco144 commented Oct 31, 2018

roster

This is what I get displaying the following component. I want there to show the full positions array and be able to update through a 'select'.

"components": [ { "name": "view_private_weekly", "type": "form", "mode": "update", "title": "Weekly Roster", "page_size": 10, "text_if_empty": "No stars :(", "query_name": "current_weekly_roster", "query_params": [], "submit_button_title": "SUBMIT ROSTER", "submit_route": "weekly_private", "edit_route": "weekly_private.edit", "edit_route_params": [ { "name": "rosterId", "value": "this._id" } ], "details_route": "weekly_private.details", "details_route_params": [ { "name": "rosterId", "value": "this._id" } ] } ]

Depth is used to set the position array to size and then it is populated with 'empty'.

@perak
Copy link
Owner

perak commented Nov 1, 2018

@maco144 sorry, but I still don't understand what you wish to have in the form: do you want multiple "select" inputs (one for each item in the array) or... ?

@maco144
Copy link
Author

maco144 commented Nov 1, 2018

@maco144 sorry, but I still don't understand what you wish to have in the form: do you want multiple "select" inputs (one for each item in the array) or... ?

@perak Yes that's exactly it. How do I get a form to display each array and allow it to be selected? Thank you.

@maco144
Copy link
Author

maco144 commented Dec 7, 2018

@perak Do you have any suggestions? I have tried using a few different methods such as events_code, helpers_code, template_rendered_code, and more without success.

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

No branches or pull requests

2 participants