0

According to https://docs.joomla.org/Plugin/Events/Content, it is Called after the data for a JForm has been retrieved. It is not very clear when exactly the event is triggered. Based on the documentation, I'd thought it is triggered after users click the submit button of a form and before the data of the form is actually submitted. But it doesn't seem so in reality.

To test it, I enabled the user-profile plugin, and in its profile.php file, I put a var_dump in the onContentPrepareData function

    public function onContentPrepareData($context, $data)
    {
        var_dump($data);
        // Check we are manipulating a valid form.
        if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile')))
        {
            return true;
        }
...

If my guess was right, when I open the editing page of a user's profile, this var_dump will only trigger after users click 'submit" button. But actually the output of var_dump is displayed when the page is loaded

0

It's triggered whenever data is loaded into a form. And that normally happens whenever a form is loaded.

When you open the profile edit page, it has a form loaded with data loaded into. If the event was not triggered, the fields added by plugins would not be populated.

| improve this answer | |
  • Thank you for your answer. Can you specify what is "whenever data is loaded into a form"? I understand "If the event was not triggered, the fields added by plugins would not be populated." What I don't understand is why forms need to be "loaded with data". For profile editing form, it must load data for users to edit, this I understand, but I can't think of other occurrences where forms need to load data. Can you please give me some other example where forms need to be loaded with data? Thank you! – shenkwen Sep 2 at 13:31
  • Sorry, I don't know how to make this any more clear than it already is. Hopefully someone else can explain. – Sharky Sep 3 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.