Hi, I’m using ObjectSelector to suggest inputs to a field on a form so that users will know what tags they’ve used before. I hit a weird error though where when using ObjectSelector to supply the values to an AutocompleteInput if someone provides a value that isn’t one of those objects then I’ll get a ValueError. Would love some suggestions on how to proceed!
Here’s a working example (just adapted from ActionExample):
class AutocompleteExample(param.Parameterized):
action = param.Action(default=lambda x: x.param.trigger('action'), label='Click here!')
show_value = param.String('Nothing loaded')
number = param.ObjectSelector(objects=['fee', 'fi', 'fo', 'fum'])
@param.depends('action')
def get_number(self):
#self.number += 1
return f'Value: {self.number}'
def view(self):
return pn.Column(pn.widgets.Button.from_param(self.param['action'], button_type = 'primary'),
pn.widgets.AutocompleteInput.from_param(self.param['number'], restrict=False),
'**Click the button** to trigger an update in the output.')
auto_example = AutocompleteExample()
pn.Row(
auto_example.view,
auto_example.get_number,
).servable()
If I run this with any of the objects from number
then it’s fine but otherwise I see ValueError: none not in parameter number's list of possible objects, valid options include [fee, fi, fo, fum]