Skip to content

Commit 1d15ec9

Browse files
authored
[com_fields] Fix wrong render_class being applied to field value after 3.9.28 (#35559)
* Make a separate field for the value class It's not good to apply the global render_class to the value. If you want a class for just the value, it should be a separate field. * Language strings for the field value class * Use value-specific class instead of render_class for the value * Add field name as as part of the field class as well * typo
1 parent 6f8d104 commit 1d15ec9

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

administrator/components/com_fields/models/forms/field.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@
288288
class="input-xxlarge"
289289
size="40"
290290
/>
291+
292+
<field
293+
name="value_render_class"
294+
type="textarea"
295+
label="COM_FIELDS_FIELD_VALUE_RENDER_CLASS_LABEL"
296+
description="COM_FIELDS_FIELD_VALUE_RENDER_CLASS_DESC"
297+
class="input-xxlarge"
298+
size="40"
299+
/>
291300

292301
<field
293302
name="showlabel"

administrator/language/en-GB/en-GB.com_fields.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ COM_FIELDS_FIELD_SHOWLABEL_LABEL="Show Label"
7373
COM_FIELDS_FIELD_TYPE_DESC="The type of the field."
7474
COM_FIELDS_FIELD_TYPE_LABEL="Type"
7575
COM_FIELDS_FIELD_USE_GLOBAL="Use settings from Plugin"
76+
COM_FIELDS_FIELD_VALUE_RENDER_CLASS_DESC="The class of the field value in the output."
77+
COM_FIELDS_FIELD_VALUE_RENDER_CLASS_LABEL="Value Class"
7678
COM_FIELDS_GROUPS_FILTER_SEARCH_DESC="Search in field group title. Prefix with ID: to search for a field group ID."
7779
COM_FIELDS_GROUP_N_ITEMS_ARCHIVED="%d field groups archived"
7880
COM_FIELDS_GROUP_N_ITEMS_ARCHIVED_1="%d field group archived"

components/com_fields/layouts/field/render.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$value = $field->value;
1919
$showLabel = $field->params->get('showlabel');
2020
$labelClass = $field->params->get('label_render_class');
21-
$renderClass = $field->params->get('render_class');
21+
$valueClass = $field->params->get('value_render_class');
2222

2323
if ($value == '')
2424
{
@@ -29,4 +29,4 @@
2929
<?php if ($showLabel == 1) : ?>
3030
<span class="field-label <?php echo $labelClass; ?>"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span>
3131
<?php endif; ?>
32-
<span class="field-value <?php echo $renderClass; ?>"><?php echo $value; ?></span>
32+
<span class="field-value <?php echo $valueClass; ?>"><?php echo $value; ?></span>

components/com_fields/layouts/fields/render.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
continue;
6060
}
6161

62-
$class = $field->params->get('render_class');
62+
$class = $field->name . ' ' . $field->params->get('render_class');
6363
$layout = $field->params->get('layout', 'render');
6464
$content = FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));
6565

0 commit comments

Comments
 (0)