Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix color field attributes onchange and required. #30743

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions layouts/joomla/form/field/color/advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,42 @@

defined('_JEXEC') or die;

use Joomla\CMS\Language\Language;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this here? I don't think it's used anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it was autamatically added by the IDE due to

 * @var   Language  $lang            Language that is active on the site.


extract($displayData);

/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to. <fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellchec Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $checked Is this field checked?
* @var array $position Is this field checked?
* @var array $control Is this field checked?
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to. <fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var string $position Position of the color picker dropdown. One of 'bottom left', 'bottom right', 'top left', or 'top right'.
* @var string $control Type of control element. One of 'hue', 'brightness', 'saturation', or 'wheel'.
* @var string $color Color representation of the value in the adequate format.
* @var string $format Format of the color representation.
* @var string $keywords Keywords for the color selector control element.
* @var Language $lang Language that is active on the site.
*/

if ($validate !== 'color' && in_array($format, array('rgb', 'rgba'), true))
Expand All @@ -65,6 +67,8 @@
$readonly = $readonly ? ' readonly' : '';
$hint = strlen($hint) ? ' placeholder="' . $this->escape($hint) . '"' : ' placeholder="' . $placeholder . '"';
$autocomplete = ! $autocomplete ? ' autocomplete="off"' : '';
$required = $required ? ' required aria-required="true"' : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aria-required="true" attribute is no longer required.

$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';

// Force LTR input value in RTL, due to display issues with rgba/hex colors
$direction = $lang->isRtl() ? ' dir="ltr" style="text-align:right"' : '';
Expand All @@ -86,7 +90,6 @@
$required,
$onchange,
$autocomplete,
$autofocus,
$format,
$keywords,
$direction,
Expand Down
18 changes: 10 additions & 8 deletions layouts/joomla/form/field/color/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,22 @@
* @var boolean $repeat Allows extensions to duplicate elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellchec Spellcheck state for the form field.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $checked Is this field checked?
* @var array $position Is this field checked?
* @var array $control Is this field checked?
* @var string $position Position of the color picker dropdown. One of 'bottom left', 'bottom right', 'top left', or 'top right'.
* @var string $color Color representation of the value in the adequate format.
* @var string $format Format of the color representation.
* @var string $keywords Keywords for the color selector control element.
* @var array $colors Set of colors to be displayed in the color picker.
* @var integer $split Number of columns for arranging the options in the color picker.
*/

$class = ' class="' . trim('simplecolors chzn-done ' . $class) . '"';
$disabled = $disabled ? ' disabled' : '';
$readonly = $readonly ? ' readonly' : '';
$required = $required ? ' required aria-required="true"' : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aria-required="true" attribute is no longer required.

$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';

// Include jQuery
JHtml::_('jquery.framework');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JHtml::_('jquery.framework');

This is surely different in J4.0

Expand All @@ -58,7 +60,7 @@
?>
<select data-chosen="true" name="<?php echo $name; ?>" id="<?php echo $id; ?>"<?php
echo $disabled; ?><?php echo $readonly; ?><?php echo $required; ?><?php echo $class; ?><?php echo $position; ?><?php
echo $onchange; ?><?php echo $autofocus; ?> style="visibility:hidden;width:22px;height:1px">
echo $onchange; ?> style="visibility:hidden;width:22px;height:1px">
<?php foreach ($colors as $i => $c) : ?>
<option<?php echo ($c == $color ? ' selected="selected"' : ''); ?>><?php echo $c; ?></option>
<?php if (($i + 1) % $split == 0) : ?>
Expand Down