The new color field without # as value

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?

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:

  1. Panel: current values will have to be updated since they don’t include the #
  2. Need to remove the # from the output

The first issue is the most annoying one.

Updating the pages should be pretty straightforward via a little script.