I am getting the message: TypeError: Attempting to open a form which is not an anvil component, (got type module), when trying to open this form

What I’m trying to do:
open a form in my M3 project. I created a form that is not designed to have the menu components but rather appear more like a popup with a Done button to go back to the launching form which is a subform of Main.Home form. The new form is of the type “Blank Panel” – When I attempt to show this form using open_form(addnewfeed) – where addnewfeed is the blank panel form, which has been imported into the launching form. I get the error message: “TypeError: Attempting to open a form which is not an anvil component, (got type module), when trying to open this form”

What I’ve tried and what’s not working:
I first searched the forum for this error message and nothing showed up.
I tried to get_open_form().content_panel.clear() and then with the content_panel add the form – that failed. The Form that I opening the subform in is also a subform of the Main.Home form. Therefore I would need to replace contents of the slot_1 apparently, but that is also not available. So I guess my best alternative is to create yet a new form based on the Main form and keep the menu on the left (although it cramps the room I need for the new form)…

Please advise and thank you.

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

You haven’t posted the code that defines symbol addnewfeed, nor a clone link, so it’s impossible to say for sure what’s going on at your end.

But let’s pick apart the error message, and try to make some educated guesses from there.

“got type module” suggests that the value of variable addnewfeed is of type module. This is what you’d get if you did a

import addnewfeed

beforehand. This kind of object is not what Anvil’s open_form function (documented here) is expecting.

Have a look at that documentation. The function expects one of two kinds of values:

  1. a string, containing the name of a Form class, or
  2. an actual class, such as you might get from
from module_name import form_class_name

where the class definition named form_class_name appears in that particular module.

That’s my best guess so far. If you’d like the volunteers here to give a better estimate, we’ll need more specific information, e.g., the code that leads up to the point of error.

3 Likes

Nope – i failed to import the form as a class. Your kindness is only exceeded by your generosity. I appreciate your time. Thank you – JM