diff --git a/administrator/components/com_modules/Field/ModulesPositioneditField.php b/administrator/components/com_modules/Field/ModulesPositioneditField.php index 381c401f6dda0..34eb76b4d61dd 100644 --- a/administrator/components/com_modules/Field/ModulesPositioneditField.php +++ b/administrator/components/com_modules/Field/ModulesPositioneditField.php @@ -38,6 +38,83 @@ class ModulesPositioneditField extends FormField */ protected $layout = 'joomla.form.field.modulespositionedit'; + /** + * Client name. + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $client; + + /** + * Method to get certain otherwise inaccessible properties from the form field object. + * + * @param string $name The property name for which to get the value. + * + * @return mixed The property value or null. + * + * @since __DEPLOY_VERSION__ + */ + public function __get($name) + { + switch ($name) + { + case 'client': + return $this->$name; + } + + return parent::__get($name); + } + + /** + * Method to set certain otherwise inaccessible properties of the form field object. + * + * @param string $name The property name for which to set the value. + * @param mixed $value The value of the property. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function __set($name, $value) + { + switch ($name) + { + case 'client': + $this->$name = (string) $value; + break; + + default: + parent::__set($name, $value); + } + } + + /** + * Method to attach a Form object to the field. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * + * @return boolean True on success. + * + * @see FormField::setup() + * @since __DEPLOY_VERSION__ + */ + public function setup(\SimpleXMLElement $element, $value, $group = null) + { + $result = parent::setup($element, $value, $group); + + if ($result === true) + { + $this->client = $this->element['client'] ? (string) $this->element['client'] : 'site'; + } + + return $result; + } + /** * Method to get the field input markup. * @@ -49,7 +126,7 @@ protected function getInput() { $data = $this->getLayoutData(); - $clientId = Factory::getApplication()->getUserState('com_modules.modules.client_id', 0); + $clientId = $this->client === 'administrator' ? 1 : 0; $positions = HTMLHelper::_('modules.positions', $clientId, 1, $this->value); $data['client'] = $clientId; diff --git a/administrator/components/com_modules/Model/ModuleModel.php b/administrator/components/com_modules/Model/ModuleModel.php index 751c6a7ee827d..2d9a3533f382e 100644 --- a/administrator/components/com_modules/Model/ModuleModel.php +++ b/administrator/components/com_modules/Model/ModuleModel.php @@ -572,8 +572,6 @@ public function getForm($data = array(), $loadData = true) return false; } - $form->setFieldAttribute('position', 'client', $this->getState('item.client_id') == 0 ? 'site' : 'administrator'); - $user = Factory::getUser(); /** diff --git a/administrator/components/com_modules/forms/module.xml b/administrator/components/com_modules/forms/module.xml index 145de7d805e96..e0a5323e1be87 100644 --- a/administrator/components/com_modules/forms/module.xml +++ b/administrator/components/com_modules/forms/module.xml @@ -92,6 +92,7 @@ label="COM_MODULES_FIELD_POSITION_LABEL" default="" maxlength="50" + client="site" /> setFieldAttribute('position', 'client', 'site'); - return $form; } diff --git a/components/com_config/forms/modules.xml b/components/com_config/forms/modules.xml index 2b9f48a1d6988..ae34158defd3a 100644 --- a/components/com_config/forms/modules.xml +++ b/components/com_config/forms/modules.xml @@ -93,6 +93,7 @@ addfieldprefix="Joomla\Component\Modules\Administrator\Field" default="" maxlength="50" + client="site" />