Cleaning file picker

Hi!
when you are saving a form, after saving it to the DB, you want to clean your input fields, for example doing this:
self.txt_comment.text = ‘’
but what about the file picker?
Is there a way to clean it, so the user is ready to pick another file after saving?
Thanks!

Hey, that’s a good question. We’ve just updated Anvil, and you can now call clear() on a FileLoader component in order to remove any files in it.

Hope that helps!

2 Likes

Will this also work for drop down menus?

Cheers,
John

Hi John,

If you’re talking about the DropDown component, you can reset those by setting the value property. (If you want to offer a “blank” option, you that should be listed in the items property)

FileLoaders are special, because you cannot write to the file property (it can only be set by the user selecting a file to upload), so they are the only component which needs a clear() method like this.

Excellent, thank you. Not sure why I was getting stuck on this :sweat_smile:

Cheers,
John