Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0113a6f
Allow jForm to support data attribute
Dec 5, 2019
3bd3edc
Update libraries/src/Form/FormField.php
Dec 5, 2019
b30c9ae
Allow jForm to support data attribute- added for remaining fields
Dec 6, 2019
bdc2d7c
Merge branch '4.0-dev' of github.com:twsvaishali/joomla-cms into 4.0-dev
Dec 6, 2019
470cb3a
Merge branch '4.0-dev' into 4.0-dev
Dec 6, 2019
7f570ff
Merge branch '4.0-dev' into 4.0-dev
Dec 6, 2019
085c323
Allow jForm to support data attribute- if condition added
Dec 7, 2019
20737ca
Merge branch '4.0-dev' of github.com:twsvaishali/joomla-cms into 4.0-dev
Dec 7, 2019
82eb0dc
Update libraries/src/Form/FormField.php
Dec 16, 2019
8c5a1d0
Update layouts/joomla/form/field/combo.php
Dec 16, 2019
ffbb469
Update libraries/src/Form/FormField.php
Dec 16, 2019
0f41ded
Update libraries/src/Form/FormField.php
Dec 16, 2019
f5204cd
Merge branch '4.0-dev' into 4.0-dev
Dec 16, 2019
32db260
Update layouts/joomla/form/field/email.php
Dec 18, 2019
18096a1
Merge branch '4.0-dev' into 4.0-dev
Dec 18, 2019
6ca6b62
Update media.php
Dec 18, 2019
4156176
Update media.php
Dec 18, 2019
f78ed6f
Merge branch '4.0-dev' into 4.0-dev
Dec 19, 2019
556f3cf
Merge branch '4.0-dev' into 4.0-dev
Dec 19, 2019
ebfdf77
Merge branch '4.0-dev' into 4.0-dev
Dec 20, 2019
c22f3c5
Merge branch '4.0-dev' into 4.0-dev
Dec 24, 2019
16bfa27
Merge branch '4.0-dev' into 4.0-dev
Jan 7, 2020
4a8ff49
Update moduleorder.php
Jan 7, 2020
66046bc
Merge branch '4.0-dev' into 4.0-dev
wilsonge Feb 16, 2020
f5aa184
Merge branch '4.0-dev' into 4.0-dev
wilsonge Mar 24, 2020
c52f30e
No concatenation when adding the attributes to the array
richard67 May 27, 2020
d46baf1
Merge branch '4.0-dev' into 4.0-dev
HLeithner May 27, 2020
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
11 changes: 11 additions & 0 deletions layouts/joomla/form/field/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @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 $dataAttributes Miscellaneous data attributes for eg, data-*.
*
* Calendar Specific
* @var string $localesPath The relative path for the locale file
Expand All @@ -64,6 +65,7 @@
*/

$inputvalue = '';
$dataAttribute = '';

// Build the attributes array.
$attributes = array();
Expand All @@ -80,6 +82,14 @@
$attributes['required'] = '';
}

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

// Handle the special case for "now".
if (strtoupper($value) === 'NOW')
{
Expand Down Expand Up @@ -113,6 +123,7 @@
value="<?php echo htmlspecialchars(($value !== '0000-00-00 00:00:00') ? $value : '', ENT_COMPAT, 'UTF-8'); ?>"
<?php echo !empty($description) ? ' aria-describedby="' . $name . '-desc"' : ''; ?>
<?php echo $attributes; ?>
<?php echo $dataAttribute; ?>
<?php echo !empty($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : ''; ?>
data-alt-value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>" autocomplete="off">
<span class="input-group-append">
Expand Down
12 changes: 11 additions & 1 deletion layouts/joomla/form/field/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var boolean $checked Whether the checkbox should be checked.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
*/

// Initialize some field attributes.
Expand All @@ -55,6 +56,15 @@
$onclick = $onclick ? ' onclick="' . $onclick . '"' : '';
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';

$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}
?>
<div class="form-check form-check-inline">
<input
Expand All @@ -63,6 +73,6 @@
id="<?php echo $id; ?>"
class="form-check-input<?php echo $class; ?>"
value="<?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); ?>"
<?php echo $checked . $disabled . $onclick . $onchange . $required . $autofocus; ?>
<?php echo $checked . $disabled . $onclick . $onchange . $required . $autofocus . $dataAttribute; ?>
>
</div>
15 changes: 13 additions & 2 deletions layouts/joomla/form/field/color/advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @var array $checked Is this field checked?
* @var array $position Is this field checked?
* @var array $control Is this field checked?
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
*/

if ($validate !== 'color' && in_array($format, array('rgb', 'rgba'), true))
Expand Down Expand Up @@ -71,11 +72,20 @@
// Force LTR input value in RTL, due to display issues with rgba/hex colors
$direction = $lang->isRtl() ? ' dir="ltr" style="text-align:right"' : '';

$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $value)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"';
}
}

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->usePreset('minicolors')
->useScript('field.color-adv');

?>
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="<?php echo $this->escape($color); ?>"<?php
echo $hint,
Expand All @@ -91,5 +101,6 @@
$format,
$keywords,
$direction,
$validate;
$validate,
$dataAttribute;
?>/>
12 changes: 11 additions & 1 deletion layouts/joomla/form/field/color/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@
* @var array $position Is this field checked?
* @var array $control Is this field checked?
* @var array $colors The specified colors
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
*/

$class = ' class="custom-select ' . trim($class) . '"';
$disabled = $disabled ? ' disabled' : '';
$readonly = $readonly ? ' readonly' : '';
$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $value)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"';
}
}

Factory::getDocument()->getWebAssetManager()
->useStyle('webcomponent.field-simple-color')
Expand All @@ -60,7 +70,7 @@
?>
<joomla-field-simple-color text-select="<?php echo Text::_('JFIELD_COLOR_SELECT'); ?>" text-color="<?php echo Text::_('JFIELD_COLOR_VALUE'); ?>" text-close="<?php echo Text::_('JLIB_HTML_BEHAVIOR_CLOSE'); ?>" text-transparent="<?php echo Text::_('JFIELD_COLOR_TRANSPARENT'); ?>">
<select 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 $disabled; ?><?php echo $readonly; ?><?php echo $dataAttribute; ?><?php echo $required; ?><?php echo $class; ?><?php echo $position; ?><?php
echo $onchange; ?><?php echo $autofocus; ?> style="visibility:hidden;width:22px;height:1px">
<?php foreach ($colors as $i => $c) : ?>
<option<?php echo ($c === $color ? ' selected="selected"' : ''); ?> value="<?php echo $c; ?>"></option>
Expand Down
12 changes: 12 additions & 0 deletions layouts/joomla/form/field/combo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $options Options available for this field.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
*/

HTMLHelper::_('behavior.combobox');

$attr = '';
$dataAttribute = '';

// Initialize some field attributes.
$attr .= !empty($class) ? ' class="awesomplete form-control ' . $class . '"' : ' class="awesomplete form-control"';
Expand All @@ -56,6 +58,15 @@

// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $value)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"';
}
}

$val = [];

foreach ($options as $option)
Expand All @@ -70,4 +81,5 @@
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $attr; ?>
data-list="<?php echo implode(', ', $val); ?>"
<?php echo $dataAttribute; ?>
/>
13 changes: 13 additions & 0 deletions layouts/joomla/form/field/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
*/

$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

$attributes = array(
$spellcheck ? '' : 'spellcheck="false"',
!empty($size) ? 'size="' . $size . '"' : '',
Expand All @@ -60,7 +71,9 @@
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
$required ? 'required' : '',
$autofocus ? 'autofocus' : '',
$dataAttribute,
);

?>
<input
type="email"
Expand Down
13 changes: 13 additions & 0 deletions layouts/joomla/form/field/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,21 @@
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/

$maxSize = HTMLHelper::_('number.bytes', Utility::getMaxUploadSize());

$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

?>
<input type="file"
name="<?php echo $name; ?>"
Expand All @@ -60,6 +72,7 @@
<?php echo !empty($multiple) ? ' multiple' : ''; ?>
<?php echo $disabled ? ' disabled' : ''; ?>
<?php echo $autofocus ? ' autofocus' : ''; ?>
<?php echo $dataAttribute; ?>
<?php echo !empty($onchange) ? ' onchange="' . $onchange . '"' : ''; ?>
<?php echo $required ? ' required' : ''; ?>><br>
<?php echo Text::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
13 changes: 12 additions & 1 deletion layouts/joomla/form/field/hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,27 @@
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/

// Initialize some field attributes.
$class = !empty($class) ? ' class="' . $class . '"' : '';
$disabled = $disabled ? ' disabled' : '';
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';

$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $value)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"';
}
}
?>
<input
type="hidden"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $class, $disabled, $onchange; ?>>
<?php echo $class, $disabled, $onchange, $dataAttribute; ?>>
11 changes: 11 additions & 0 deletions layouts/joomla/form/field/list-fancy-select.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,27 @@
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/

$html = array();
$attr = '';
$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

// Initialize the field attributes.
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
$attr .= $multiple ? ' multiple' : '';
$attr .= $autofocus ? ' autofocus' : '';
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
$attr .= $dataAttribute;

// To avoid user's confusion, readonly="readonly" should imply disabled="disabled".
if ($readonly || $disabled)
Expand Down
11 changes: 11 additions & 0 deletions layouts/joomla/form/field/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/

$html = array();
$attr = '';
$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

// Initialize the field attributes.
$attr .= !empty($class) ? ' class="custom-select ' . $class . '"' : ' class="custom-select"';
Expand All @@ -56,6 +66,7 @@
$attr .= $autofocus ? ' autofocus' : '';
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
$attr .= !empty($description) ? ' aria-describedby="' . $name . '-desc"' : '';
$attr .= $dataAttribute;

// To avoid user's confusion, readonly="readonly" should imply disabled="disabled".
if ($readonly || $disabled)
Expand Down
45 changes: 28 additions & 17 deletions layouts/joomla/form/field/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,42 @@
* Layout variables
* ---------------------
*
* @var string $asset The asset text
* @var string $authorField The label text
* @var integer $authorId The author id
* @var string $class The class text
* @var boolean $disabled True if field is disabled
* @var string $folder The folder text
* @var string $id The label text
* @var string $link The link text
* @var string $name The name text
* @var string $preview The preview image relative path
* @var integer $previewHeight The image preview height
* @var integer $previewWidth The image preview width
* @var string $onchange The onchange text
* @var boolean $readonly True if field is readonly
* @var integer $size The size text
* @var string $value The value text
* @var string $src The path and filename of the image
* @var string $asset The asset text
* @var string $authorField The label text
* @var integer $authorId The author id
* @var string $class The class text
* @var boolean $disabled True if field is disabled
* @var string $folder The folder text
* @var string $id The label text
* @var string $link The link text
* @var string $name The name text
* @var string $preview The preview image relative path
* @var integer $previewHeight The image preview height
* @var integer $previewWidth The image preview width
* @var string $onchange The onchange text
* @var boolean $readonly True if field is readonly
* @var integer $size The size text
* @var string $value The value text
* @var string $src The path and filename of the image
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/
extract($displayData);

$attr = '';
$dataAttribute = '';

if (!empty($dataAttributes))
{
foreach ($dataAttributes as $key => $attrValue)
{
$dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
}
}

// Initialize some field attributes.
$attr .= !empty($class) ? ' class="form-control field-media-input ' . $class . '"' : ' class="form-control field-media-input"';
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
$attr .= $dataAttribute;

// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';
Expand Down
Loading