-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,42 +7,44 @@ | |
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
use Joomla\CMS\Language\Language; | ||
|
||
defined('_JEXEC') or die; | ||
Harmageddon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 Is this field checked? TODO | ||
* @var string $control Is this field checked? TODO | ||
* @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)) | ||
|
@@ -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"' : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
$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"' : ''; | ||
|
@@ -86,7 +90,6 @@ | |
$required, | ||
$onchange, | ||
$autocomplete, | ||
$autofocus, | ||
$format, | ||
$keywords, | ||
$direction, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,20 +34,23 @@ | |
* @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 Is this field checked? TODO | ||
* @var string $control Is this field checked? TODO | ||
* @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"' : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : ''; | ||
|
||
// Include jQuery | ||
JHtml::_('jquery.framework'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is surely different in J4.0 |
||
|
@@ -58,7 +61,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) : ?> | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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