This code will only work in the constructor. That could be mentioned in the docs.
That was weird, took me a bit to track to down. Looks like the issue is in your AddonBakery common class:
$this->EE->load->add_package_path(PATH_THIRD); // add common lib folder to package path
You’re setting an add-on package path to the root THIRD_PARTY
folder, which makes that the last package path loaded before your MCP controller methods are called. So it doesn’t know which package to look for your file in the subsequent ee()->cp->load_package_js('simple_registration');
call. If you get rid of that, it works fine everywhere. 😊
You’re adding a package path that isn’t to a package, you’re just adding THIRD_PARTY
. Your addon’s package path is already added. If you add another one afterwards, that package’s path will be the current path in context, making your addon’s package no longer the one in context.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.