Skip to content

Commit

Permalink
[fix] switch_field preview
Browse files Browse the repository at this point in the history
Currently has 1 opacity. Needs 0.5 for default WinterCMS disabled state
  • Loading branch information
AIC-BV authored Feb 26, 2024
1 parent d9ff4e0 commit 5d234c3
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions modules/backend/widgets/form/partials/_field_switch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
?>

<!-- Switch -->
<div class="field-switch">
<label for="<?= $field->getId() ?>"><?= e(trans($field->label)) ?></label>
<?php if ($field->comment): ?>
<p class="help-block"><?= $field->commentHtml ? trans($field->comment) : e(trans($field->comment)) ?></p>
<?php endif ?>
</div>

<input
type="hidden"
name="<?= $field->getName() ?>"
value="0"
<?= $previewMode ? 'disabled="disabled"' : '' ?>>
<div class="<?= $previewMode ? 'disabled' : '' ?>">
<div class="field-switch">
<label for="<?= $field->getId() ?>"><?= e(trans($field->label)) ?></label>
<?php if ($field->comment): ?>
<p class="help-block"><?= $field->commentHtml ? trans($field->comment) : e(trans($field->comment)) ?></p>
<?php endif ?>
</div>

<label class="custom-switch" <?= $previewMode ? 'onclick="return false"' : '' ?>>
<input
type="checkbox"
id="<?= $field->getId() ?>"
type="hidden"
name="<?= $field->getName() ?>"
value="1"
<?= $previewMode ? 'readonly="readonly"' : '' ?>
<?= $field->value == 1 ? 'checked="checked"' : '' ?>
<?= $field->getAttributes() ?>>
<span><span><?= e(trans($on)) ?></span><span><?= e(trans($off)) ?></span></span>
<a class="slide-button"></a>
</label>
value="0">

<label class="custom-switch" <?= $previewMode ? 'onclick="return false"' : '' ?>>
<input
type="checkbox"
id="<?= $field->getId() ?>"
name="<?= $field->getName() ?>"
value="1"
<?= $previewMode ? 'readonly="readonly"' : '' ?>
<?= $field->value == 1 ? 'checked="checked"' : '' ?>
<?= $field->getAttributes() ?>>
<span><span><?= e(trans($on)) ?></span><span><?= e(trans($off)) ?></span></span>
<a class="slide-button"></a>
</label>
</div>

0 comments on commit 5d234c3

Please sign in to comment.