J3 Issue ?
avatar brainforgeUK
brainforgeUK
6 Feb 2018

Steps to reproduce the issue

I was looking for a fields plugin event called when an article using customs fields (com_field) is saved.
I found FormModel::validate() function triggers onUserBeforeDataValidation event.

Adding function onUserBeforeDataValidation($form, &data) to my field plugin produces the functionality I require.

Expected result

(a) Documentation for the onUserBeforeDataValidation event
(b) A more meaningful event name e.g. onFormModelBeforeDataValidation

Actual result

(a) I could not find any documentation for this event
(b) Looks like original author for this event was too focused on the user problem they wanted to solve and not thinking of the wider applications of this event.

System information (as much as possible)

Joomla 3.8.4

Additional comments

Suggest changing FormModel::validate() function to something like the following:

if (get_class($this) == 'UsersModelUser') {
// Obsolete, kept here for backward compatibility
$dispatcher->trigger('onUserBeforeDataValidation', array($form, &$data));
}
$dispatcher->trigger('onFormModelDataValidation', array($form, &$data));

avatar brainforgeUK brainforgeUK - open - 6 Feb 2018
avatar joomla-cms-bot joomla-cms-bot - change - 6 Feb 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Feb 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Feb 2018
Category com_plugins
avatar garstud
garstud - comment - 25 Feb 2018

Interesting subject!
a) The code is located in /libraries/src/MVC/Model/FormModel.php in line 355 :

$dispatcher->trigger('onUserBeforeDataValidation', array($form, &$data));

There is 2 parameters :

  • $form : the form object to validate against
  • $data : input data that will be validate after this event

b) I agree, the name of this event should be updated to onForm... or onContent... (like the others triggered events in this class)

avatar franz-wohlkoenig franz-wohlkoenig - change - 25 Feb 2018
Status New Discussion
avatar brianteeman brianteeman - change - 25 Mar 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar brianteeman
brianteeman - comment - 9 Apr 2018

Pull requests are welcome

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Apr 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-04-12 15:15:19
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 12 Apr 2018
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 12 Apr 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 12 Apr 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 12 Apr 2018

closed as having Pull Request #20152

Add a Comment

Login with GitHub to post a comment