J3 Issue ?
avatar infograf768
infograf768
23 Apr 2018

Steps to reproduce the issue

Create a new custom LIST field for articles. (Same pb with Checkbox, did not test all)
For example:
screen shot 2018-04-23 at 07 36 42

Then edit an article and choose a value. For example "Center"
screen shot 2018-04-23 at 07 51 19

Then, following the instructions in https://docs.joomla.org/J3.x:Adding_custom_fields/Overrides
edit /components/com_content/views/article/tmpl/default.php

Add after $info = etc.

foreach($this->item->jcfields as $jcfield)
{
    $this->item->jcFields[$jcfield->name] = $jcfield;
}

and thereafter
var_dump($this->item->jcFields['article_class']->value); Where article_class is the name of my field.

Expected result

center

Actual result

Center

What has happened?

In fact, for some of the custom fields, $value = $rawvalue. It is the case for the custom Text field.
But it is not the case for List, Checkboxes, and maybe others I did not check.

For these, the real value is $rawvalue.
The code to use is therefore

$this->item->jcFields['article_class']->rawvalue

Obviously the docs should be updated to reflect this confusion.
I propose to also add a spacer label displaying when editing these fields.
Any other solution in code would not be B/C

What do you think?

@laoneo

avatar infograf768 infograf768 - open - 23 Apr 2018
avatar joomla-cms-bot joomla-cms-bot - change - 23 Apr 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Apr 2018
avatar laoneo
laoneo - comment - 23 Apr 2018

Docs do need to be updated for sure.

avatar franz-wohlkoenig franz-wohlkoenig - change - 23 Apr 2018
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 23 Apr 2018
Category com_fields Documentation
avatar brianteeman brianteeman - change - 23 Apr 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 23 Apr 2018
avatar infograf768
infograf768 - comment - 25 Apr 2018

Modified docs.

avatar infograf768 infograf768 - change - 30 Apr 2018
Status Discussion Known Issue
Closed_Date 0000-00-00 00:00:00 2018-04-30 07:55:09
Closed_By infograf768
Labels
avatar infograf768 infograf768 - change - 30 Apr 2018
Labels
avatar infograf768 infograf768 - close - 30 Apr 2018
avatar infograf768
infograf768 - comment - 30 Apr 2018

Changed to Known Issue. Does not mean it is right, but, at this stage, it can't be modified for B/C reasons.


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

avatar audetcameron
audetcameron - comment - 24 May 2019

Each Article = Multiple Custom Fields and using List Type/Select fields.

We were using

  echo $item->jcFields['work-project-types']->value

However since a recent update this is now blank.
My friend Justin found that we needed to go into the back end and enable the Show On (BOTH) option. In order to get the value to display again.
image

avatar ReLater
ReLater - comment - 24 May 2019

@audetcameron

Maybe your find is a new issue. It was reported on a German forum for Joomla 3.9.5 like this:

Before update the ->value was the Text of the selected list OPTION.
Before update the ->rawvalue was the Value of the selected list OPTION.

After update the ->value is empty.

I've tested it and couldn't confirm the issue but my setting for Show on was Both (= Default).

Add a Comment

Login with GitHub to post a comment