Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use FormModelInterface::getForm() method outside of a component execution #43347

Open
artur-stepien opened this issue Apr 24, 2024 · 0 comments

Comments

@artur-stepien
Copy link
Contributor

Steps to reproduce the issue

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.

Expected result

Form is being loaded.

Actual result

could not load file error

System information (as much as possible)

Joomla 4.x, 5.x and 6.x

Additional comments

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants