johan
December 8, 2023, 8:35pm
1
Hi,
Currently updating to v4 and looking at the new color field. Nice!
One issue though is that the color fields I created for v3 didn’t have the actual # in the value.
Question is, is it possible to exclude the # from the new color field? And use # as a prefix again. This would make life easier migrating to the new field. Otherwise all color fields will need to manually be updated or something.
Best,
Johan
Not without changing how the field works, because of how Kirby validates the saved field values.
What is the code for the output?
Isn’t it a better way to remove the # character in the output and use the new core features of Kirby?
johan
December 9, 2023, 10:06am
4
Here’s an example of what I’m currently using:
custom:
before: #
label: Custom
pattern: ^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
type: text
<?php if ($backgroundPageColor->custom()->isNotEmpty()): ?>
main.bg-color-custom {
background: #<?= $backgroundPageColor->custom() ?>;
}
<?php endif ?>
There are two issues:
Panel: current values will have to be updated since they don’t include the #
Need to remove the # from the output
The first issue is the most annoying one.
texnixe
December 9, 2023, 10:55am
5
Updating the pages should be pretty straightforward via a little script.