Skip to content
Open
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
6 changes: 6 additions & 0 deletions modules/backend/classes/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ class FormField
*/
public $preset;

/**
* @var bool Should the field's label for checkbox/switch fields be displayed above the field.
*/
public $showLabels;

/**
* Constructor.
* @param string $fieldName The name of the field
Expand Down Expand Up @@ -296,6 +301,7 @@ protected function evalConfig($config)
'preset',
'readOnly',
'required',
'showLabels',
'stretch',
'trigger',
];
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/widgets/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ protected function getFieldDepends($field)
protected function showFieldLabels($field)
{
if (in_array($field->type, ['checkbox', 'switch', 'section'])) {
return false;
return $field->showLabels ?? false;
}

if ($field->type === 'widget') {
Expand Down
10 changes: 7 additions & 3 deletions modules/backend/widgets/form/partials/_field_checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name="<?= $field->getName() ?>"
value="0"
<?= $this->previewMode ? 'disabled="disabled"' : '' ?>>

<input
type="checkbox"
id="<?= $field->getId() ?>"
Expand All @@ -14,10 +15,13 @@
<?= $field->isSelected() ? 'checked="checked"' : '' ?>
<?= $field->getAttributes() ?>>

<label for="<?= $field->getId() ?>">
<?= e(trans($field->label)) ?>
<label for="<?= $field->getId() ?>" class="<?= $field->showLabels ? 'show-labels' : '' ?>">
<?php if (!$field->showLabels): ?>
<?= e(trans($field->label)) ?>
<?php endif ?>
</label>
<?php if ($field->comment): ?>

<?php if (!$field->showLabels and $field->comment): ?>
<p class="help-block"><?= $field->commentHtml ? trans($field->comment) : e(trans($field->comment)) ?></p>
<?php endif ?>
</div>
6 changes: 4 additions & 2 deletions modules/backend/widgets/form/partials/_field_switch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<!-- Switch -->
<div class="<?= $previewMode ? 'disabled' : '' ?>">
<div class="field-switch">
<label for="<?= $field->getId() ?>"><?= e(trans($field->label)) ?></label>
<?php if ($field->comment): ?>
<?php if (!$field->showLabels): ?>
<label for="<?= $field->getId() ?>"><?= e(trans($field->label)) ?></label>
<?php endif ?>
<?php if (!$field->showLabels and $field->comment): ?>
<p class="help-block"><?= $field->commentHtml ? trans($field->comment) : e(trans($field->comment)) ?></p>
<?php endif ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion modules/system/assets/js/build/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/system/assets/js/snowboard/build/snowboard.base.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading