J3 Issue ?
avatar rolandalsace
rolandalsace
12 Apr 2019

Hi.

Joomla 3.9.5

It's not possible to change the allowAdd attribute of the JFormField categoryedit to false.

In /administrator/component/com_categories/models/fields/categoryedit.php

line : 59 we set $this->allowAdd to blank or to a simplexmlelement

line : 344 if ($this->allowAdd)
{

Here we tests $this->allowAdd as booleen, so when it's an SimpleXMLElement (wich is generaly the case),
this test return always true.

So if we make a
$form->setFieldAttribute('catid','allowAdd','false');

This have no effect, and worse it is interpreted as true.

Regards

Steps to reproduce the issue

Always

Expected result

Actual result

System information (as much as possible)

Additional comments

avatar rolandalsace rolandalsace - open - 12 Apr 2019
avatar joomla-cms-bot joomla-cms-bot - labeled - 12 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Apr 2019
Labels Added: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 12 Apr 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Apr 2019

@HLeithner can you please comment?

avatar franz-wohlkoenig franz-wohlkoenig - change - 13 Apr 2019
Status New Information Required
avatar rolandalsace
rolandalsace - comment - 13 Apr 2019

Hi Franz.

What do you want to know else ?

With x-debug i see that (see in my description above) that in line 344 of /administrator/component/com_categories/models/fields/categoryedit.php
$this->allowAdd is tested as booleen and as this variable is of type SimpleXMLElement, the condition is always true.

So a $form->setFieldAttribute('catid','allowAdd','false'); has no effect.

I do not see what I can explain in more detail.

Regards.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Apr 2019

What do you want to know else ?

i'm calling Harald as Release Lead, i'm user no Dev.

avatar rolandalsace
rolandalsace - comment - 13 Apr 2019

I suggest to change in line 57 of /administrator/component/com_categories/models/fields/categoryedit.php

$this->allowAdd = isset($this->element['allowAdd']) ? $this->element['allowAdd'] : '';

by

$this->allowAdd = isset($this->element['allowAdd']) ? (bool)filter_var((((array)$this->element->attributes())['@attributes']['allowAdd']), FILTER_VALIDATE_BOOLEAN) : '';

This solve the problème.

Regards.


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

avatar rolandalsace
rolandalsace - comment - 13 Apr 2019

or

$this->allowAdd = isset($this->element['allowAdd']) ? (bool)filter_var((((array)$this->element->attributes())['@attributes']['allowAdd']), FILTER_VALIDATE_BOOLEAN) : false;


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24566.
avatar alikon
alikon - comment - 13 Apr 2019

please do pr

avatar hardik-codes
hardik-codes - comment - 13 Apr 2019

please test #24574

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Apr 2019

Closed as having Pull Request.

avatar franz-wohlkoenig franz-wohlkoenig - change - 13 Apr 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-04-13 09:50:10
Closed_By franz-wohlkoenig
avatar franz-wohlkoenig franz-wohlkoenig - close - 13 Apr 2019

Add a Comment

Login with GitHub to post a comment