No Code Attached Yet
avatar frogydiak
frogydiak
30 Mar 2022

Steps to reproduce the issue

Open the plugin Fields - List and add some options:
Fields - List

Then create a field of list type in an article for example:
Articles Fields - List

Now go and create a new article, look at the Field Tab to see the field.
Articles: New - Fields

According to the code in FieldsListPlugin.php at line#73:

`public function getOptionsFromField($field)
{
$data = array();

// Fetch the options from the plugin
$params = clone $this->params;
$params->merge($field->fieldparams);

foreach ($params->get('options', array()) as $option)
{
$op = (object) $option;
$data[$op->value] = $op->name;
}

return $data;
}`

It should merge the parameters from the plugin settings and in the field, right? Unless, I am reading the code wrong, am I?

Expected result

The list options/params I set in the plugin settings: One and Two should be merged into the options I added in the Field edit.

Actual result

The list field only pull options from the field edit.

avatar frogydiak frogydiak - open - 30 Mar 2022
avatar joomla-cms-bot joomla-cms-bot - change - 30 Mar 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 30 Mar 2022
avatar varaprasad16
varaprasad16 - comment - 18 Apr 2022

Hello, this is Vara Prasad I've gone through the error and related code, and I saw that the error is occurring due to the merge method that you've used in line 73(according to the new code).

avatar richard67
richard67 - comment - 18 Apr 2022

To me it seems that this is desired behaviour. See the description of PR #13578 :

After this PR you will only see the ones from the field. The plugin ones are only shown if none are defined in the field.

@Bakual Can you confirm this?

avatar Bakual
Bakual - comment - 18 Apr 2022

This is expected. The field overwrites the plugin defaults.

avatar richard67 richard67 - close - 18 Apr 2022
avatar richard67 richard67 - change - 18 Apr 2022
Status New Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2022-04-18 15:50:04
Closed_By richard67
avatar richard67
richard67 - comment - 18 Apr 2022

Closing as expected behaviour due to reasons mentioned in previous comments.


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

avatar frogydiak
frogydiak - comment - 4 May 2022

I see, understand now but there should be a text/description in the plugin parameters that the default values defined will be overwritten if values are defined in the field parameters.

avatar Bakual
Bakual - comment - 5 May 2022

I don't think it needs a text. The behavior is the same as in every other place. Default parameters get overwritten, not merged.
You just happend to have wrong expections in this case because you had your use case. If your use case would have been different, you wouldn't have expected this behavior at all.

Add a Comment

Login with GitHub to post a comment