Forms and Inheritance

I’m looking into reusing code patterns that I use regularly and I’ve hit a problem…

If I create a form that derives from a base class, it works perfectly well when I instantiate it and show it in my app. Great. So far, so good.

However, if I try to instantiate exactly the same form to show as an alert, it doesn’t work.

Here’s an MWE showing the same form being added to the app’s Main.content_panel (which works) and a button which attempts to open it as an alert (which does not):

https://anvil.works/build#clone:AVGCVJ6CJFLT3RLH=PXMJIWGFZWVUXAY7GGHNFEBH

Any ideas as to what might be going on here?

Good spot. We’ve got a fix and this should go live soon.

For now if you swap the inheritance order (i.e. make the Template Form class the first class in the list of bases) then it should work just fine.

1 Like

Excellent! Thank you.

(Your MRO suggestion does indeed make the MWE work but messes up my real app - probably because I also use a decorator from my navigation library. I’ll wait for the fix…)

1 Like