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; //...
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners