Skip to content

Commit

Permalink
feature(forms): allow custom required indicators for field labels
Browse files Browse the repository at this point in the history
You can now pass required_indicator parameter to elgg_view_input() to override
default indicator view
  • Loading branch information
hypeJunction committed Nov 3, 2015
1 parent 4777f5c commit f29fbb6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions views/default/elements/forms/label.php
Expand Up @@ -4,6 +4,7 @@
* Form input label view
*
* @uses $vars['label'] HTML content of the label element
* @uses $vars['required_indicator'] Override required indicator with a custom view, or set to a false value to not render it
* @uses $vars['id'] ID attribute of the input element
*/
$label = elgg_extract('label', $vars, '');
Expand All @@ -15,10 +16,16 @@
}

if ($required) {
$label .= elgg_format_element('span', [
'title' => elgg_echo('field:required'),
'class' => 'elgg-required-indicator',
], "*");
$indicator = elgg_extract('required_indicator', $vars);
if (!isset($indicator)) {
$indicator = elgg_format_element('span', [
'title' => elgg_echo('field:required'),
'class' => 'elgg-required-indicator',
], "*");
}
if ($indicator) {
$label .= $indicator;
}
}

echo elgg_format_element('label', [
Expand Down

0 comments on commit f29fbb6

Please sign in to comment.