PR-staging RTC

Pending

User tests: Successful: Unsuccessful:

avatar tonypartridge
tonypartridge
24 Mar 2018

Pull Request for Issue #16177.

List custom field rawvalue should always return an array.

Summary of Changes

Added a check and convert string to array if needed.

Testing Instructions

RawValue should always return as an array for list, so var_dump() on jcfields ie with:

echo '<pre>';
var_dump($this->item->jcfields);
die;

the list type should always be an array with 1 value or two.

Expected result

RawValue should always return as an array for list

Actual result

RawValue is a string if only 1 value is selected.

avatar tonypartridge tonypartridge - open - 24 Mar 2018
avatar tonypartridge tonypartridge - change - 24 Mar 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Mar 2018
Category Administration com_fields
avatar laoneo
laoneo - comment - 25 Mar 2018

I would prefer a solution where the field itself can set up the raw value. A possible way can be with a new plugin event. Hardcoding field types in the model should be avoided.

avatar tonypartridge
tonypartridge - comment - 25 Mar 2018

That's a good point @laoneo and exactly why I wanted your input :-) I only did the PR as a proof of concept of what we want to achieve basically. Will take a look at adding a new event

avatar tonypartridge tonypartridge - change - 25 Mar 2018
Title
Staging com fields list always array rawvalue
[com_fields] List field to always return array.
avatar tonypartridge tonypartridge - edited - 25 Mar 2018
avatar tonypartridge tonypartridge - change - 25 Mar 2018
Labels Added: PR-staging
avatar joomla-cms-bot joomla-cms-bot - change - 25 Mar 2018
Category Administration com_fields Administration com_fields Front End Plugins
avatar tonypartridge
tonypartridge - comment - 25 Mar 2018

PR updated, please test.

@laoneo I was able to handle it with onCustomFieldsPrepareField :-)

avatar tonypartridge tonypartridge - change - 25 Mar 2018
The description was changed
avatar tonypartridge tonypartridge - edited - 25 Mar 2018
avatar tonypartridge tonypartridge - change - 25 Mar 2018
The description was changed
avatar tonypartridge tonypartridge - edited - 25 Mar 2018
avatar tonypartridge tonypartridge - change - 25 Mar 2018
The description was changed
avatar tonypartridge tonypartridge - edited - 25 Mar 2018
avatar laoneo
laoneo - comment - 26 Mar 2018

Nice one.

avatar tonypartridge
tonypartridge - comment - 27 Mar 2018

Thanks @Quy updated :-)

avatar Quy
Quy - comment - 29 Mar 2018

Now a custom text field's rawvalue is converted to an array. I added a var_dump to the function and access the frontend to check the rawvalue.

avatar laoneo
laoneo - comment - 29 Mar 2018

@Quy see my comment here #19978 (comment)

avatar tonypartridge
tonypartridge - comment - 29 Mar 2018

thanks @laoneo I just assumed it would only be processed by the field type. I've added the change, @Quy can you test again please?

avatar tonypartridge
tonypartridge - comment - 3 Apr 2018

Drone said spaces weren’t allowed! Arghh.

On 3 Apr 2018, 03:21 +0100, Quy notifications@github.com, wrote:

@Quy commented on this pull request.
In plugins/fields/list/list.php:

    • @param string $context The context.
  •    * @param   stdclass  $item     The item.
    
  •    * @param   stdclass  $field    The field.
    
  •    *
    
  •    * @return  object
    
  •    *
    
  •    * @since   __DEPLOY_VERSION__
    
  •    */
    
  •   public function onCustomFieldsPrepareField($context, $item, $field)
    
  •   {
    
  •           // Check if the field should be processed
    
  •           if (!$this->isTypeSupported($field->type))
    
  •           {
    
  •                   return;
    
  •           }
    

Remove tab.

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

avatar tonypartridge
tonypartridge - comment - 26 Oct 2018

@laoneo @Quy @carcam @GeraintEdwards
can we get some tests? Would be nice to clear this off.

avatar Quy
Quy - comment - 24 Nov 2018

Tested with staging when editing an article on the backend.

Call to undefined method FieldsHelper::displayFieldOnForm()
\joomla-cms-staging\administrator\components\com_fields\libraries\fieldsplugin.php:156 


Call stack
--
# | Function | Location
1 | () | JROOT\administrator\components\com_fields\libraries\fieldsplugin.php:156
2 | FieldsPlugin->onCustomFieldsPrepareDom() | JROOT\administrator\components\com_fields\libraries\fieldslistplugin.php:33
3 | FieldsListPlugin->onCustomFieldsPrepareDom() | JROOT\libraries\joomla\event\event.php:70
4 | JEvent->update() | JROOT\libraries\joomla\event\dispatcher.php:160
5 | JEventDispatcher->trigger() | JROOT\libraries\src\Application\BaseApplication.php:108
6 | Joomla\CMS\Application\BaseApplication->triggerEvent() | JROOT\administrator\components\com_fields\helpers\fields.php:459
7 | FieldsHelper::prepareForm() | JROOT\plugins\system\fields\fields.php:288
8 | PlgSystemFields->onContentPrepareForm() | JROOT\libraries\joomla\event\event.php:70
9 | JEvent->update() | JROOT\libraries\joomla\event\dispatcher.php:160
10 | JEventDispatcher->trigger() | JROOT\libraries\src\MVC\Model\FormModel.php:321
11 | Joomla\CMS\MVC\Model\FormModel->preprocessForm() | JROOT\administrator\components\com_content\models\article.php:834
12 | ContentModelArticle->preprocessForm() | JROOT\libraries\src\MVC\Model\FormModel.php:242
13 | Joomla\CMS\MVC\Model\FormModel->loadForm() | JROOT\administrator\components\com_content\models\article.php:374
14 | ContentModelArticle->getForm() | JROOT\libraries\src\MVC\View\HtmlView.php:425
15 | Joomla\CMS\MVC\View\HtmlView->get() | JROOT\administrator\components\com_content\views\article\view.html.php:63
16 | ContentViewArticle->display() | JROOT\libraries\src\MVC\Controller\BaseController.php:672
17 | Joomla\CMS\MVC\Controller\BaseController->display() | JROOT\administrator\components\com_content\controller.php:54
18 | ContentController->display() | JROOT\libraries\src\MVC\Controller\BaseController.php:710
19 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT\administrator\components\com_content\content.php:21
20 | require_once() | JROOT\libraries\src\Component\ComponentHelper.php:402
21 | Joomla\CMS\Component\ComponentHelper::executeComponent() | JROOT\libraries\src\Component\ComponentHelper.php:377
22 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT\libraries\src\Application\AdministratorApplication.php:101
23 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT\libraries\src\Application\AdministratorApplication.php:159
24 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT\libraries\src\Application\CMSApplication.php:196
25 | Joomla\CMS\Application\CMSApplication->execute() | JROOT\administrator\index.php:51

avatar tonypartridge
tonypartridge - comment - 21 Dec 2018

@Quy unfortunately your issue has nothing to do with my Pr. I've just tested it with latest staging 3.9.2-dev and all is fine. Furthermore, your error is to do with displayFieldOnForm() which isn't called by this plugin, this plugin only runs on onCustomFieldsPrepareField() which returns a string or an array. Always returning an array for lists is the same as if it has multiple values.

e99a4e7 21 Dec 2018 avatar Quy cs
avatar Quy
Quy - comment - 21 Dec 2018

You're right. It must be with PatchTester. Applying manually results in no errors.

avatar Quy
Quy - comment - 21 Dec 2018

I have tested this item successfully on da7c39f


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

avatar Quy Quy - test_item - 21 Dec 2018 - Tested successfully
avatar viocassel
viocassel - comment - 25 Dec 2018

I have tested this item successfully on da7c39f


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

avatar viocassel
viocassel - comment - 25 Dec 2018

I have tested this item successfully on da7c39f


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

avatar viocassel viocassel - test_item - 25 Dec 2018 - Tested successfully
avatar Quy Quy - change - 25 Dec 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 25 Dec 2018

RTC


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

avatar mbabker mbabker - change - 27 Dec 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-12-27 18:57:00
Closed_By mbabker
Labels Added: RTC
avatar mbabker mbabker - close - 27 Dec 2018
avatar mbabker mbabker - merge - 27 Dec 2018

Add a Comment

Login with GitHub to post a comment