From 8dba541de324672866ceaa29bc029d0d5d168253 Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Thu, 10 Jan 2019 11:13:58 +0000 Subject: [PATCH 1/2] Custom Fields - display units It is very common to need to display a unit of measurement with a field. Currently there is no way to do this without creating custom layouts for every field and every unit when needed. This PR adds a new param to every custom field "Suffix" which allows you to add a unit of measurement (or any other text) to be rendered after the value of the field. The new field is disabled by default so three is no b/c issue ### To test Apply the pr and then create a new custom field and you will see the new Suffix param in the render options. ## Example usage ### Before ### After --- .../com_fields/models/forms/field.xml | 22 +++++++++++++++++++ .../language/en-GB/en-GB.com_fields.ini | 4 ++++ .../com_fields/layouts/field/render.php | 6 +++++ 3 files changed, 32 insertions(+) diff --git a/administrator/components/com_fields/models/forms/field.xml b/administrator/components/com_fields/models/forms/field.xml index 5de6ea4522f98..9567abf779485 100644 --- a/administrator/components/com_fields/models/forms/field.xml +++ b/administrator/components/com_fields/models/forms/field.xml @@ -307,6 +307,28 @@ showon="showlabel:1" /> + + + + + + + value; $showLabel = $field->params->get('showlabel'); $labelClass = $field->params->get('label_render_class'); +$showSuffix = $field->params->get('showsuffix'); +$suffix = $field->params->get('suffix'); + if ($value == '') { @@ -29,3 +32,6 @@ : + + + From 0973b87f3a6b49945070aee77a981a18a693ea6f Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Fri, 11 Jan 2019 13:18:26 +0000 Subject: [PATCH 2/2] plurals --- components/com_fields/layouts/field/render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/com_fields/layouts/field/render.php b/components/com_fields/layouts/field/render.php index 350bfc2538d6e..a8c70ed68a0e7 100644 --- a/components/com_fields/layouts/field/render.php +++ b/components/com_fields/layouts/field/render.php @@ -19,7 +19,7 @@ $showLabel = $field->params->get('showlabel'); $labelClass = $field->params->get('label_render_class'); $showSuffix = $field->params->get('showsuffix'); -$suffix = $field->params->get('suffix'); +$suffix = JText::plural($field->params->get('suffix'), $value); if ($value == '')