? No Code Attached Yet
avatar Flowman
Flowman
16 Sep 2022

Steps to reproduce the issue

Right now we can inject a custom form into preprocessForm with onContentPrepareForm event from a plugin group.

Issue is when trying to save the form it does not inject the plugin group name into preprocessForm and the controller validation remove the custom data entered into the form data.

This line should be extended with the plugin group value of the preprocessForm function. As right now it will always load the 'content' group and there is no way to override it.

$this->preprocessForm($form, $data);

Expected result

Be able to load plugin group for preprocessForm on save.

Actual result

Not possible.

System information (as much as possible)

Joomla 4.2

Additional comments

Maybe add an $options['group'] as the would be hard to extend the loadForm function with a new parameter.

Example:
$this->preprocessForm($form, $data, $options['group']);

avatar Flowman Flowman - open - 16 Sep 2022
avatar joomla-cms-bot joomla-cms-bot - change - 16 Sep 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Sep 2022
avatar Fedik
Fedik - comment - 16 Sep 2022

Sounds valid.

Note: Currently if you use own model, you can override preprocessForm and load your plugin group

protected function preprocessForm(Form $form, $data, $group = 'content')
{
// Import the appropriate plugin group.
PluginHelper::importPlugin($group);
// Trigger the form preparation event.
Factory::getApplication()->triggerEvent('onContentPrepareForm', array($form, $data));
}

 PluginHelper::importPlugin('my-plugin-group');
avatar Fedik Fedik - change - 16 Sep 2022
Labels Added: ?
avatar Fedik Fedik - labeled - 16 Sep 2022
avatar Flowman
Flowman - comment - 16 Sep 2022

True didn't think of that. But would be nice if core fixed it out of the box.

Add a Comment

Login with GitHub to post a comment