Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions layouts/joomla/form/renderfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('showon');
}
$class = empty($options['class']) ? '' : ' ' . $options['class'];
$rel = empty($options['rel']) ? '' : ' ' . $options['rel'];
$id = $name . '-desc';
$hide = empty($options['hiddenLabel']) ? '' : ' sr-only';

$class = empty($options['class']) ? '' : ' ' . $options['class'];
$rel = empty($options['rel']) ? '' : ' ' . $options['rel'];
$id = $name . '-desc';
$hide = empty($options['hiddenLabel']) ? '' : ' sr-only';
$hideDescription = empty($options['hiddenDescription']) ? false : $options['hiddenDescription'];
?>
<div class="control-group<?php echo $class; ?>"<?php echo $rel; ?>>
<div class="control-label<?php echo $hide; ?>"><?php echo $label; ?></div>
<div class="controls">
<?php echo $input; ?>
<?php if (!empty($description)) : ?>
<?php if (!$hideDescription && !empty($description)) : ?>
<div id="<?php echo $id; ?>">
<small class="form-text text-muted">
<?php echo $description; ?>
Expand Down
16 changes: 16 additions & 0 deletions libraries/src/Form/Field/NoteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ class NoteField extends FormField
*/
protected $type = 'Note';

/**
* Hide the label when rendering the form field.
*
* @var boolean
* @since 4.0.0
*/
protected $hiddenLabel = true;

/**
* Hide the description when rendering the form field.
*
* @var boolean
* @since 4.0.0
*/
protected $hiddenDescription = true;

/**
* Method to get the field label markup.
*
Expand Down
32 changes: 30 additions & 2 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ abstract class FormField
*/
protected $hiddenLabel = false;

/**
* Should the description be hidden when rendering the form field? This may be useful if you have the
* description rendering in your form field itself for e.g. note fields.
*
* @var boolean
* @since 4.0.0
*/
protected $hiddenDescription = false;

/**
* True to translate the field label string.
*
Expand Down Expand Up @@ -1027,9 +1036,28 @@ public function renderField($options = array())

$options['rel'] = '';

if (empty($options['hiddenLabel']) && $this->getAttribute('hiddenLabel') || $this->hiddenLabel)
if (empty($options['hiddenLabel']))
{
$options['hiddenLabel'] = true;
if ($this->getAttribute('hiddenLabel'))
{
$options['hiddenLabel'] = $this->getAttribute('hiddenLabel') == 'true' ? true : false;
}
else
{
$options['hiddenLabel'] = $this->hiddenLabel;
}
}

if (empty($options['hiddenDescription']))
{
if ($this->getAttribute('hiddenDescription'))
{
$options['hiddenDescription'] = $this->getAttribute('hiddenDescription') == 'true' ? true : false;
}
else
{
$options['hiddenDescription'] = $this->hiddenDescription;
}
}

if ($this->showon)
Expand Down