Skip to content

[Bug] "switch" field 'color' option is not working in theme-tabler #5735

@kiddtang

Description

@kiddtang

Bug report

What I did

try to use "switch" field

[
    'name' => 'enabled',
    'label' => 'Enabled',
    'type' => 'switch',
    'default' => true,
    'color'    => '#00ff00',
],

What I expected to happen

image
it should be in color '#00ff00',

What happened

<label class="form-switch switch switch-sm switch-label switch-pill switch-#00ff00 mb-0" style="--bg-color: #00ff00;">
            <input type="hidden" name="enabled" value="1">
            <input type="checkbox" data-init-function="bpFieldInitSwitch" checked="true" class="switch-input form-check-input" id="switch_enabled_770978383386580500" data-initialized="true">
            <span class="switch-slider" data-checked="" data-unchecked="">
            </span>
        </label>

the style style="--bg-color: #00ff00;" is in the field DOM but not reflected correctly.

What I've already tried to fix it

Override the styles

.form-check-input:checked {
  background-color: var(--bg-color, var(--tblr-primary)) !important;
}

but this only work if the color is defined in hex, not string 'primary'.

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?
Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:
backpack/basset: 1.3.6
backpack/crud: 6.7.43
backpack/filemanager: 3.0.10
backpack/generators: v4.0.7
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.29
backpack/settings: 3.1.1
backpack/theme-tabler: 1.2.15

Metadata

Metadata

Assignees

Labels

Minor BugA bug that happens only in a very niche or specific use case.Priority: SHOULD

Type

No type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions