diff --git a/administrator/components/com_fields/helpers/fields.php b/administrator/components/com_fields/helpers/fields.php
index 52c9c46c19136..029ea680b4bed 100644
--- a/administrator/components/com_fields/helpers/fields.php
+++ b/administrator/components/com_fields/helpers/fields.php
@@ -542,6 +542,52 @@ public static function canEditFieldValue($field)
return JFactory::getUser()->authorise('core.edit.value', $parts[0] . '.field.' . (int) $field->id);
}
+ /**
+ * Return a boolean based on field (and field group) display / show_on settings
+ *
+ * @param stdClass $field The field
+ *
+ * @return boolean
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public static function displayFieldOnForm($field)
+ {
+ $app = JFactory::getApplication();
+
+ // Detect if the field should be shown at all
+ if ($field->params->get('show_on') == 1 && $app->isClient('administrator'))
+ {
+ return false;
+ }
+ elseif ($field->params->get('show_on') == 2 && $app->isClient('site'))
+ {
+ return false;
+ }
+
+ if (!self::canEditFieldValue($field))
+ {
+ $fieldDisplayReadOnly = $field->params->get('display_readonly', '2');
+
+ if ($fieldDisplayReadOnly == '2')
+ {
+ // Inherit from field group display read-only setting
+ $groupModel = JModelLegacy::getInstance('Group', 'FieldsModel', array('ignore_request' => true));
+ $groupDisplayReadOnly = $groupModel->getItem($field->group_id)->params->get('display_readonly', '1');
+ $fieldDisplayReadOnly = $groupDisplayReadOnly;
+ }
+
+ if ($fieldDisplayReadOnly == '0')
+ {
+ // Do not display field on form when field is read-only
+ return false;
+ }
+ }
+
+ // Display field on form
+ return true;
+ }
+
/**
* Adds Count Items for Category Manager.
*
diff --git a/administrator/components/com_fields/libraries/fieldsplugin.php b/administrator/components/com_fields/libraries/fieldsplugin.php
index 9cf4eb6bb3e36..3a88cb0e774e3 100644
--- a/administrator/components/com_fields/libraries/fieldsplugin.php
+++ b/administrator/components/com_fields/libraries/fieldsplugin.php
@@ -152,14 +152,8 @@ public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form
return null;
}
- $app = JFactory::getApplication();
-
- // Detect if the field should be shown at all
- if ($field->params->get('show_on') == 1 && $app->isClient('administrator'))
- {
- return;
- }
- elseif ($field->params->get('show_on') == 2 && $app->isClient('site'))
+ // Detect if the field is configured to be displayed on the form
+ if (!FieldsHelper::displayFieldOnForm($field))
{
return null;
}
diff --git a/administrator/components/com_fields/models/forms/field.xml b/administrator/components/com_fields/models/forms/field.xml
index 17de81827a690..7958234104aaf 100644
--- a/administrator/components/com_fields/models/forms/field.xml
+++ b/administrator/components/com_fields/models/forms/field.xml
@@ -287,6 +287,19 @@
+
+
+
+
+
+
diff --git a/administrator/components/com_fields/models/forms/group.xml b/administrator/components/com_fields/models/forms/group.xml
index 03a6619019378..4ed5c46842c27 100644
--- a/administrator/components/com_fields/models/forms/group.xml
+++ b/administrator/components/com_fields/models/forms/group.xml
@@ -89,8 +89,8 @@
filter="user_utc"
/>
-
+
+
+
+
diff --git a/administrator/components/com_fields/models/group.php b/administrator/components/com_fields/models/group.php
index d8f8c087ed470..cf9147f815af4 100644
--- a/administrator/components/com_fields/models/group.php
+++ b/administrator/components/com_fields/models/group.php
@@ -8,6 +8,8 @@
*/
defined('_JEXEC') or die;
+use Joomla\Registry\Registry;
+
/**
* Group Model
*
@@ -69,6 +71,11 @@ public function save($data)
*/
public function getTable($name = 'Group', $prefix = 'FieldsTable', $options = array())
{
+ if (strpos(JPATH_COMPONENT, 'com_fields') === false)
+ {
+ $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_fields/tables');
+ }
+
return JTable::getInstance($name, $prefix, $options);
}
@@ -314,6 +321,11 @@ public function getItem($pk = null)
$item->context = $this->getState('filter.context');
}
+ if (property_exists($item, 'params'))
+ {
+ $item->params = new Registry($item->params);
+ }
+
// Convert the created and modified dates to local user time for display in the form.
$tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
diff --git a/administrator/components/com_fields/models/groups.php b/administrator/components/com_fields/models/groups.php
index 93ddb6632d00c..a3f822df48d89 100644
--- a/administrator/components/com_fields/models/groups.php
+++ b/administrator/components/com_fields/models/groups.php
@@ -8,6 +8,7 @@
*/
defined('_JEXEC') or die;
+use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
@@ -213,4 +214,31 @@ protected function getListQuery()
return $query;
}
+
+ /**
+ * Gets an array of objects from the results of database query.
+ *
+ * @param string $query The query.
+ * @param integer $limitstart Offset.
+ * @param integer $limit The number of records.
+ *
+ * @return array An array of results.
+ *
+ * @since __DEPLOY_VERSION__
+ * @throws RuntimeException
+ */
+ protected function _getList($query, $limitstart = 0, $limit = 0)
+ {
+ $result = parent::_getList($query, $limitstart, $limit);
+
+ if (is_array($result))
+ {
+ foreach ($result as $group)
+ {
+ $group->params = new Registry($group->params);
+ }
+ }
+
+ return $result;
+ }
}
diff --git a/administrator/language/en-GB/en-GB.ini b/administrator/language/en-GB/en-GB.ini
index b4078de2faa2d..9eca04c2ef18b 100644
--- a/administrator/language/en-GB/en-GB.ini
+++ b/administrator/language/en-GB/en-GB.ini
@@ -203,6 +203,8 @@ JFIELD_BASIS_LOGOUT_DESCRIPTION_LABEL="Logout Description Text"
JFIELD_BASIS_LOGOUT_DESCRIPTION_SHOW_DESC="Show or hide logout description."
JFIELD_BASIS_LOGOUT_DESCRIPTION_SHOW_LABEL="Logout Description"
JFIELD_CATEGORY_DESC="The category that this item is assigned to. You may select an existing category or enter a new category by typing the name in the field and pressing enter."
+JFIELD_DISPLAY_READONLY_DESC="Whether to display the field on forms when read-only. Inherit defaults to value set in field group."
+JFIELD_DISPLAY_READONLY_LABEL="Display When Read-Only"
JFIELD_ENABLED_DESC="The enabled status of this item."
JFIELD_FIELDS_CATEGORY_DESC="Select the category that this field is assigned to."
JFIELD_KEY_REFERENCE_DESC="Used to store information referring to an external resource."