I’m having issues with my dropdown selections not being passed to a dictionary if I don’t change the initial selection:
Here you can see my form where I have chosen the initial selection on my dropdown
Thanks for your reply. Is it possible to provide the clone link privately?
In terms of code for the form and save button:
def button_new_control_click(self, **event_args):
# Initialise an empty dictionary to store the user inputs
new_control = {}
# Open an alert displaying the 'Control_Form' Form
save_clicked = alert(content=File_Control_Form(item=new_control),
title="Add Control",
large=True,
buttons=[("Save", True), ("Cancel", False)],
)
# If the alert returned 'True', the save button was clicked.
if save_clicked:
anvil.server.call('add_quick_file_control', new_control)
self.__init__()
Generally it’s a good idea to provide a clone link that only demonstrate the behaviour that is causing the issue.
It’ll help others to debug the code.
So if it’s possible to decouple the issue into a smaller app that’ll help a lot - and will also mean you don’t have to worry about sharing sensitive data.
From the snippets it looks like you’re providing an empty dictionary as the item.
Writeback databindings won’t update unless the user interacts with the component so I’m not surprised that you’re getting a key error here if the user hasn’t changed the dropdown, and the item was initially an empty dictionary.
You could pre-populate the self.item in the __init__ method - or do a validation before the server call.
# something like this in the init method
self.item.update({'Owner': 'someowner'}) # provide some default values
self.refresh_data_bindings()
Hi @stucork, thanks for your reply. I added a placeholder in the dropdown and a validation to the UI so users would have to select a dropdown item. Thanks again!