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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners