diff --git a/administrator/components/com_users/views/users/tmpl/modal.php b/administrator/components/com_users/views/users/tmpl/modal.php index 1a67f0da7d7fe..c4e8fe918155b 100644 --- a/administrator/components/com_users/views/users/tmpl/modal.php +++ b/administrator/components/com_users/views/users/tmpl/modal.php @@ -30,8 +30,10 @@
- + get('required', 0, 'INT') != 1 ) : ?> + +
diff --git a/administrator/templates/isis/html/layouts/joomla/form/field/media.php b/administrator/templates/isis/html/layouts/joomla/form/field/media.php index 85ae295eabc17..b44b66ffb077d 100644 --- a/administrator/templates/isis/html/layouts/joomla/form/field/media.php +++ b/administrator/templates/isis/html/layouts/joomla/form/field/media.php @@ -11,25 +11,41 @@ /** * 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. 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 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 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 $preview The preview image relative path + * @var integer $previewHeight The image preview height + * @var integer $previewWidth The image preview width + * @var string $asset The asset text + * @var string $authorField The label text + * @var string $folder The folder text + * @var string $link The link text */ extract($displayData); diff --git a/administrator/templates/isis/html/layouts/joomla/form/field/user.php b/administrator/templates/isis/html/layouts/joomla/form/field/user.php index 2c609f57aa42f..bd34dce372b81 100644 --- a/administrator/templates/isis/html/layouts/joomla/form/field/user.php +++ b/administrator/templates/isis/html/layouts/joomla/form/field/user.php @@ -13,26 +13,51 @@ /** * 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. 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 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 string $id The DOM id of the element - * @var string $name The name of the field - * @var boolean $required The required attribute - * @var mixed $value The value of the field (user id) - * @var string $class The CSS class to apply - * @var integer $size The ize for the input element - * @var mixed $groups The filtering groups (null means no filtering) - * @var mixed $exclude The users to exclude from the list of users - * @var string $onchange The script for on change event - * @var string $userName The user name - * @var boolean $readOnly Check for field read only attribute + * @var string $userName The user name + * @var mixed $groups The filtering groups (null means no filtering) + * @var mixed $exclude The users to exclude from the list of users */ // Set the link for the user selection page -$link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field={field-user-id}' +$link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&required=' + . ($required ? 1 : 0) . '&field={field-user-id}' . (isset($groups) ? ('&groups=' . base64_encode(json_encode($groups))) : '') . (isset($excluded) ? ('&excluded=' . base64_encode(json_encode($excluded))) : ''); +// Invalidate the input value if no user selected +if (JText::_('JLIB_FORM_SELECT_USER') == htmlspecialchars($userName, ENT_COMPAT, 'UTF-8')) +{ + $userName = ""; +} + JHtml::script('jui/fielduser.min.js', false, true, false, false, true); ?> @@ -47,13 +72,14 @@ >
/> - + + /> + 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 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 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 $preview The preview image relative path + * @var integer $previewHeight The image preview height + * @var integer $previewWidth The image preview width + * @var string $asset The asset text + * @var string $authorField The label text + * @var string $folder The folder text + * @var string $link The link text */ extract($displayData); diff --git a/layouts/joomla/form/field/user.php b/layouts/joomla/form/field/user.php index 2b63586c2dcab..0905e6651b2de 100644 --- a/layouts/joomla/form/field/user.php +++ b/layouts/joomla/form/field/user.php @@ -13,25 +13,50 @@ /** * 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. 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 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 string $id The DOM id of the element - * @var string $name The name of the field - * @var boolean $required The required attribute - * @var mixed $value The value of the field (user id) - * @var string $class The CSS class to apply - * @var integer $size The ize for the input element - * @var mixed $groups The filtering groups (null means no filtering) - * @var mixed $exclude The users to exclude from the list of users - * @var string $onchange The script for on change event - * @var string $userName The user name - * @var boolean $readOnly Check for field read only attribute + * @var string $userName The user name + * @var mixed $groups The filtering groups (null means no filtering) + * @var mixed $exclude The users to exclude from the list of users */ -$link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $id +$link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&required=' + . ($required ? 1 : 0) . '&field={field-user-id}' . (isset($groups) ? ('&groups=' . base64_encode(json_encode($groups))) : '') . (isset($excluded) ? ('&excluded=' . base64_encode(json_encode($excluded))) : ''); +// Invalidate the input value if no user selected +if (JText::_('JLIB_FORM_SELECT_USER') == htmlspecialchars($userName, ENT_COMPAT, 'UTF-8')) +{ + $userName = ""; +} + // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal_' . $id); @@ -40,11 +65,13 @@
/> - + + /> + diff --git a/libraries/cms/form/field/user.php b/libraries/cms/form/field/user.php index e7662d8d64f5b..6d52c31334989 100644 --- a/libraries/cms/form/field/user.php +++ b/libraries/cms/form/field/user.php @@ -92,16 +92,10 @@ public function getLayoutData() $table->name = JText::_('JLIB_FORM_SELECT_USER'); } - // Initialize JavaScript field attributes. - $onchange = (string) $this->element['onchange']; - $extraData = array( - 'onchange' => $onchange, 'userName' => $table->name, 'groups' => $this->getGroups(), - 'excluded' => $this->getExcluded(), - 'readOnly' => $this->readonly, - 'class' => $this->class, + 'excluded' => $this->getExcluded() ); return array_merge($data, $extraData); diff --git a/media/jui/js/fielduser.js b/media/jui/js/fielduser.js index c81f3a9bc868f..ffc1f0a288d0a 100644 --- a/media/jui/js/fielduser.js +++ b/media/jui/js/fielduser.js @@ -123,7 +123,7 @@ function jSelectUser(element) { name = $el.data('user-name'), fieldId = $el.data('user-field'), $inputValue = jQuery('#' + fieldId + '_id'), - $inputName = jQuery('#' + fieldId + '_name'); + $inputName = jQuery('#' + fieldId); if (!$inputValue.length) { // The input not found diff --git a/media/jui/js/fielduser.min.js b/media/jui/js/fielduser.min.js index dd6ed1d7a162b..5bc9b3e6a1279 100644 --- a/media/jui/js/fielduser.min.js +++ b/media/jui/js/fielduser.min.js @@ -1 +1 @@ -function jSelectUser(t){var e=jQuery(t),i=e.data("user-value"),o=e.data("user-name"),n=e.data("user-field"),a=jQuery("#"+n+"_id"),s=jQuery("#"+n+"_name");if(a.length){a.val(i).trigger("change"),s.val(o||i).trigger("change");var d,l=a.attr("data-onchange");l&&(d=new Function(l),d.call(a[0])),jModalClose()}}!function(t){"use strict";t.fieldUser=function(e,i){this.options=t.extend({},t.fieldUser.defaults,i),this.$container=t(e),this.$modal=this.$container.find(this.options.modal),this.$modalBody=this.$modal.children(".modal-body"),this.$input=this.$container.find(this.options.input),this.$inputName=this.$container.find(this.options.inputName),this.$buttonSelect=this.$container.find(this.options.buttonSelect),this.$buttonSelect.on("click",this.modalOpen.bind(this)),this.$modal.on("hide",this.removeIframe.bind(this));var o,n=this.$input.attr("data-onchange");n&&(o=new Function(n),this.$input.on("change",o.bind(this.$input)))},t.fieldUser.prototype.modalOpen=function(){var e=t("