Unable to use FormModelInterface::getForm()
method outside of a component execution. Because FormBehaviorTrait::loadForm()
uses JPATH_COMPONENT
constant to register paths to form object. This results in a could not load file
error when trying to load form on a page where desired component is not loaded or in cli/scheduled task. I consider it a bug as component booting doesn't apparently boot the component fully.
Form is being loaded.
could not load file
error
Joomla 4.x, 5.x and 6.x
The root of this problem is this part in line 73 of https://github.com/joomla/joomla-cms/blob/4.4-dev/libraries/src/MVC/Model/FormBehaviorTrait.php
// Get the form.
Form::addFormPath(JPATH_COMPONENT . '/forms');
Form::addFormPath(JPATH_COMPONENT . '/models/forms');
Form::addFieldPath(JPATH_COMPONENT . '/models/fields');
Form::addFormPath(JPATH_COMPONENT . '/model/form');
Form::addFieldPath(JPATH_COMPONENT . '/model/field');
I would propose to register those paths in Joomla\CMS\MVC\Factory\MVCFactory::createModel()
method to avoid issues when component is booted outside of component execution.
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
bug
|