Customize field group titles in the listing form
- Thread started
- Last updated
What you’ll achieve
Replace a field group heading with custom HTML and an explanatory paragraph in listing forms.
My site
Replace a field-group heading in the listing form with your own heading and explanatory paragraph. To change only the title, use Field Groups Manager.
Keep the customization in your JReviews overrides. Start a new PHP file with <?php followed by defined('MVC_FRAMEWORK') or die;. In an existing file, add the callback without repeating the opening tag or guard. If a snippet includes those lines, keep each only once.
JReviews 6 Early Access
Enable Listing Form in Early Access. This hook changes listing forms only; it does not change advanced search or the detail page.
Add the PHP code to your overrides
Joomla. Add the PHP example to templates/jreviews_overrides/hooks.php.
WordPress. Add the PHP example to jreviews_overrides/hooks.php.
Add the heading before the group's first field
Identify the first field in your target group. This example uses jr_hotelname. Replace that field name in the hook registration with your first field's name. Keep that field active for every submitting group that needs to see the header.
fwd_add_action('jreviews:listing_form.before_field:jr_hotelname', function ($field, $listing, $fieldGroups): void {
echo <<<'HTML'
<div class="guide-hotel-intro">
<h3>Hotel information</h3>
<p>Enter the hotel's public name and contact details so visitors can identify and contact the property.</p>
</div>
HTML;
}, 20, 3);
Style the heading
Joomla. Add the CSS to templates/jreviews_overrides/resources/css/custom.css.
WordPress. Add the CSS to jreviews_overrides/resources/css/custom.css.
The first selector hides the normal heading only in a modern listing form group containing jr_hotelname. The custom header then appears before that first field. Replace the field name in the selector when adapting the example.
[data-jr-listing-form] [data-jr-field-group]:has([name="fields[jr_hotelname]"]) > h3 {
display: none;
}
[data-jr-listing-form] .guide-hotel-intro {
background: var(--fwd-surface-subtle);
border: 1px solid var(--fwd-border);
border-radius: .5rem;
padding: 1rem;
}
[data-jr-listing-form] .guide-hotel-intro h3 {
margin: 0 0 .5rem;
font-size: 1.25rem;
font-weight: 600;
}
[data-jr-listing-form] .guide-hotel-intro p {
margin: 0;
}
Use a field that remains visible. If a permission or dependency hides the first field, this field-specific hook does not run. For a tabbed form, the tab label still comes from the group title; update that title too.
JReviews 5 and v6 Legacy
Replace a matching field-group legend with a custom heading and explanatory paragraph in both new-listing and edit forms.
Add the code to your overrides
Joomla. Use templates/jreviews_overrides/filters/filter_functions.php.
WordPress. Use jreviews_overrides/filters/filter_functions.php.
Replace a form legend
The code replaces the group heading, called a legend in the form HTML. It works both when you edit a listing and when JReviews loads the fields for a new listing.
Clickfwd\Hook\Filter::add('after_filter_output_listings_edit', 'jreviews_replace_form_group_titles');
Clickfwd\Hook\Filter::add('after_filter_output_listings__loadForm', 'jreviews_replace_form_group_titles');
function jreviews_replace_form_group_titles($output, $params)
{
if (!is_string($output) || $output === '') {
return $output;
}
$decoded = json_decode($output, true);
$isHtmlOutput = json_last_error() !== JSON_ERROR_NONE || !is_array($decoded);
if ($isHtmlOutput) {
$tmp = $output;
} else {
if (!isset($decoded['html']) || !is_string($decoded['html'])) {
return $output;
}
$output = $decoded;
$tmp = $output['html'];
}
// Replace the "Hotel Info" field group legend tag with an HTML header
$hotelHeader = <<<HTML
<div class="fwd-bg-teal-600 fwd-rounded-t-lg fwd-text-white fwd-p-4">
<h3 class="fwd-font-bold fwd-text-2xl">Hotel information</h3>
<p class="fwd-text-base">Enter the hotel's public name and contact details so visitors can identify and contact the property.</p>
</div>
HTML;
$tmp = str_replace('<legend>Hotel Info</legend>', $hotelHeader, $tmp);
if ($isHtmlOutput) {
return $tmp;
}
$output['html'] = $tmp;
return json_encode($output);
}
Match your group title
In the str_replace line, replace Hotel Info with your current group heading. Replace Hotel information and the explanatory paragraph in the example with your content. If the heading does not change, open the form, right-click its group heading, and choose Inspect. Find the <legend>...</legend> element and copy its complete HTML into the first quoted value in str_replace. The match must include the same tags, spaces, and heading text.
The fwd- classes require matching styles in your legacy theme. Use your own classes if those utilities are unavailable.
Check new and existing listing forms
Start a new listing and edit an existing listing. Confirm that the replacement heading and paragraph appear once in the intended group. Other group headings must remain unchanged. Check every submitting group that needs the heading.
Learn more
- Custom Fields (v5)
- Custom Field PHP Formatting (v5)
- Custom Fields (v6)
- Custom Field Output Formatting (v6)
- Hooks (v6)
- Themes and overrides (v6)