? Failure

User tests: Successful: Unsuccessful:

avatar hardik-codes
hardik-codes
13 Apr 2019

Pull Request for Issue #24566

Summary of Changes

Changed

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

to

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

in administrator/components/com_categories/models/fields/categoryedit.php

Testing Instructions

Code Inspection

Documentation Changes Required

None

avatar hardik-codes hardik-codes - open - 13 Apr 2019
avatar hardik-codes hardik-codes - change - 13 Apr 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Apr 2019
Category Administration com_categories
avatar hardik-codes hardik-codes - change - 14 Apr 2019
Labels Added: ?
avatar HLeithner
HLeithner - comment - 14 Apr 2019

I think thats the wrong approach, it should be solved more generic.

Also there is missing that the attribute name as value is also true.

avatar HLeithner
HLeithner - comment - 14 Apr 2019

Maybe adding 1 or 2 helper function in JForm getting attribute values, they should work for "all" get attribute use cases. At least for boolean and string or a combination of this.

avatar ggppdk
ggppdk - comment - 14 Apr 2019

Maybe adding 1 or 2 helper function in JForm getting attribute values, they should work for "all" get attribute use cases. At least for boolean and string or a combination of this.

Yes at minimum for boolean-like attributes, would be nice

This has come up before, the check of boolean-like attributes is not consistent, at every place that such an attribute is used it may be checked a different way, some examples:

  • Some are just compared to == 'true'
    e.g. $hidden = $element['hidden'] == 'true'; in menuhelper

  • Some are checked if their are not equal to 'false' and not '0' and not zero length string (mean ="foo" is evaluated as true)
    e.g. Joomla\CMS\Form;

						$showTime = (string) $element['showtime'];
						$showTime = ($showTime && $showTime != 'false');

This is pr will also allow values "on" "off" and "yes", "no", etc, ??
which i think is a new case of compare if true

avatar HLeithner
HLeithner - comment - 14 Apr 2019

I would like to reduce possible values as less as possible to have a consistent codebase, at least for the future...

so adding new possible values makes it more confusing.

avatar rolandalsace
rolandalsace - comment - 15 Apr 2019

Actualy it's a bug, when the allowAdd attribute is present, it's allways consider as true, and you cannot remove an attribute.
And i think that the soluce proposed solve the problem (and i have the problem).
After it's perhaps a good soluce to have a common and more simple function to test a simpleXMLElement value and more specificaly a boolean value.

avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Apr 2019
Title
[staging] Fix allowAdd attribute of the JFormField categoryedit
Fix allowAdd attribute of the JFormField categoryedit
avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Apr 2019
Title
[staging] Fix allowAdd attribute of the JFormField categoryedit
Fix allowAdd attribute of the JFormField categoryedit
avatar franz-wohlkoenig franz-wohlkoenig - edited - 18 Apr 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 Apr 2019

@hardik-codes can you please comment?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Jul 2019

@hardik-codes whats the Status of this Pull Request?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Jul 2019

closed due the lack of response.

avatar franz-wohlkoenig franz-wohlkoenig - close - 20 Jul 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Jul 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-07-20 09:51:21
Closed_By franz-wohlkoenig

Add a Comment

Login with GitHub to post a comment