?
avatar ced1870
ced1870
16 May 2017

Steps to reproduce the issue

Create a plugin with an event "onContentPrepareForm" like this

public function onContentPrepareForm($form, $data) {
if (count($data)) {
// get article params
$attribs = $data->get('attribs');
}
}

Edit an article and try to change its category. The fatal error appears that the get does not exists.

Expected result

$data shall be the associated data for the form.

Actual result

$data is empty

System information (as much as possible)

Joomla! 3.7.0

Additional comments

On article loading, $data returns a JObect

when switching the category, the $data in the article returns a simple Array

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar ced1870 ced1870 - open - 16 May 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 May 2017
avatar ced1870 ced1870 - change - 16 May 2017
The description was changed
avatar ced1870 ced1870 - edited - 16 May 2017
avatar ced1870 ced1870 - change - 16 May 2017
The description was changed
avatar dgt41
dgt41 - comment - 16 May 2017

Try this:

public function onContentPrepareForm($form, $data) {
   if (isset($data) && count($data)) {
      // get article params
      $attribs = $data->get('attribs');
   }
}
avatar ced1870
ced1870 - comment - 16 May 2017

this is not correct because I'm still in the article and I need to edit the attribs

I have used this to avoid the error, but the problem is in the fact that $data shall be a JObject and not an Array

if (method_exists($data,'get')) {
$attribs = $data->get('attribs');
} else if (isset($data['attribs'])) {
$attribs = $data['attribs'];
}


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

avatar dgt41
dgt41 - comment - 16 May 2017

That was my misunderstanding, yes you are right $data should remain JObject

avatar rdeutz
rdeutz - comment - 16 May 2017

You need to figure out what type of data you get, take a look at this: https://github.com/joomla/joomla-cms/blob/staging/plugins/system/fields/fields.php#L194

avatar ced1870
ced1870 - comment - 16 May 2017

I'm already checking the context, I'm in 'com_content.article' in both cases

this problem was not there before the 3.7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

avatar rdeutz
rdeutz - comment - 16 May 2017

Check it with 3.6.5 it is the same you get an empty array or a jObject

avatar jjsjjs
jjsjjs - comment - 17 May 2017

I'm having an similair issue, but without a plugin as above.
Simply when creating an article and then change the category.
Please see: https://forum.joomla.org/viewtopic.php?f=706&t=950583
I have no further info then the Error itself.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

avatar ced1870
ced1870 - comment - 17 May 2017

@rdeutz : no matter in which version this has been introduced, it just does not work as expected :)


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

avatar rdeutz
rdeutz - comment - 17 May 2017

oh no, it works as expected, if you check the profile plugin you will find:


/**
    * Adds additional fields to the user editing form
    *
    * @param   JForm  $form  The form to be altered.
    * @param   mixed  $data  The associated data for the form.
    *
    * @return  boolean
    *
    * @since   1.6
    */

$data has a type of mixed. No question that this is not a brillant idea to have different types for a parameter but thats's how it is.

Closing not a bug

avatar rdeutz rdeutz - change - 17 May 2017
The description was changed
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-05-17 11:44:49
Closed_By rdeutz
avatar rdeutz rdeutz - close - 17 May 2017
avatar ced1870
ced1870 - comment - 17 May 2017

ok I agree. Then we don't investigate more to change this ?
We just close it ... it's a shame


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

avatar rdeutz
rdeutz - comment - 17 May 2017

You are free to make a pull request or open a ticket with a suggestion how to change it, this ticket gives the impression we have to fix a bug.

avatar ced1870
ced1870 - comment - 17 May 2017

ok Robert I understand :)
Then it is not a bug, but something we could improve (my 2 cents).

I will then investigate.
Thanks !


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16047.

Add a Comment

Login with GitHub to post a comment