Let's spruce up our field a little bit and add some extra methods of customisation. To achieve this, we'll add a new storeColorName() method to the field and adjust the field's functionality accordingly.
public function storeColorName(bool | Closure $condition = true): static { $this->shouldStoreColorName = $condition; return $this; } public function shouldStoreColorName(): bool { return (bool) $this->evaluate($this->shouldStoreColorName); }} And making some changes in the Blade view: @php $shouldStoreColorName = $shouldStoreColorName(); @endphp @foreach($getOptions() as $color => $label) @php($value = $shouldStoreColorName ?
Let's start by adding a method like before: class ColorPalette extends Field { //... protected bool | Closure $canChooseCustomColors = false; //...