Hello everyone,
I am trying to create a join team/ club button within my app. The user selects the name of the team they would like to join from a dropdown (this is from a map list items from the team documents and the actual value recorded or set is the document ID). When they click the join button I would like the selected DocumentID to be used to retrieve the corresponding team reference so that the members field can be updated with the users reference.
How can this be done?? I have been stuck on this for over two weeks and cannot understand why I cannot do something so simple, it only ever adds the user record reference to the first dropdown option.
Here is what the page looks like with the values selected being the the DocumentID and the labels are the corresponding teamName. The second photo shows how I am currently updating the document however there is no where within that logic that uses the selected DocumentID to use a reference for updating the fields. It may be of note that the join now button queries the team collection as a single document.
Here is what the page looks like when I run it and select different items from the dropdown, as you can see the value retrieved is the corresponding documentID to that teamName.
The issue I am facing is that the button's onPressed
logic is not using the selected team's reference ID stored in _model.teamReferenceValue
. Instead, it's using the first team record from the queryTeamRecord(singleRecord: true)
stream, which is why it always adds the user to the first team.
The button's onPressed
logic needs to be modified to use the selected team's reference ID stored in _model.teamReferenceValue
.
How can I use the _model.teamReferenceValue
to get the selected team's reference so I can then use that in the update document action area?