Permalink
Browse files

feature(forms): allow custom required indicators for field labels

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 f29fbb6fb759ac4eb4c353eb3ad335c6655be607
Showing with 11 additions and 4 deletions.
  1. +11 −4 views/default/elements/forms/label.php
@@ -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, '');
@@ -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', [

0 comments on commit f29fbb6

Please sign in to comment.