F
Filament12mo ago
Mark

Undefined variable $canSelectPlaceholder using Select in Custom Field

I'm probably doing it wrong, but I'm sure someone else will manage to do it wrong the same way. I have created a custom field, based on the KeyValue field, but it allows for an additional piece of information to be entered - the type of data being wrapped in the KVP. Eventually, when dehydrating / hydrating the data, it'll be serialized to JSON. I've tried a bunch of different ways of trying to pass in the canSelectPlaceholder variable, and this is the latest iteration:
<td class="w-1/3 p-0">
<x-filament-forms::select
x-model="row.fieldType"
:disabled="(! $canEditFieldTypes()) || $isDisabled"
:canSelectPlaceholder="$canSelectPlaceholder()"
:attributes="
\Filament\Support\prepare_inherited_attributes(
new \Illuminate\View\ComponentAttributeBag([
'x-on:input.debounce.' . ($debounce ?? '500ms') => 'updateState',
])
)
"
class="font-mono"
>
@foreach ($getFieldTypes() as $fieldType => $fieldTypeLabel)
<option value="{{ $fieldType }}">{{ $fieldTypeLabel }}</option>
@endforeach
</x-filament-forms::select>
</td>
<td class="w-1/3 p-0">
<x-filament-forms::select
x-model="row.fieldType"
:disabled="(! $canEditFieldTypes()) || $isDisabled"
:canSelectPlaceholder="$canSelectPlaceholder()"
:attributes="
\Filament\Support\prepare_inherited_attributes(
new \Illuminate\View\ComponentAttributeBag([
'x-on:input.debounce.' . ($debounce ?? '500ms') => 'updateState',
])
)
"
class="font-mono"
>
@foreach ($getFieldTypes() as $fieldType => $fieldTypeLabel)
<option value="{{ $fieldType }}">{{ $fieldTypeLabel }}</option>
@endforeach
</x-filament-forms::select>
</td>
1 Reply
Mark
MarkOP12mo ago
I figured it out. I needed to change it over to kebab case. It still threw some errors about not being callable until I changed it out to a closure. Here's the final code:
<td class="w-1/3 p-0">
<x-filament-forms::select
x-model="row.fieldType"
:disabled="(! $canEditFieldTypes()) || $isDisabled"
:can-select-placeholder="fn(): bool => false"
:attributes="
\Filament\Support\prepare_inherited_attributes(
new \Illuminate\View\ComponentAttributeBag([
'x-on:input.debounce.' . ($debounce ?? '500ms') => 'updateState',
])
)
"
class="font-mono"
>
@foreach ($getFieldTypes() as $fieldType => $fieldTypeLabel)
<option value="{{ $fieldType }}">{{ $fieldTypeLabel }}</option>
@endforeach
</x-filament-forms::select>
</td>
<td class="w-1/3 p-0">
<x-filament-forms::select
x-model="row.fieldType"
:disabled="(! $canEditFieldTypes()) || $isDisabled"
:can-select-placeholder="fn(): bool => false"
:attributes="
\Filament\Support\prepare_inherited_attributes(
new \Illuminate\View\ComponentAttributeBag([
'x-on:input.debounce.' . ($debounce ?? '500ms') => 'updateState',
])
)
"
class="font-mono"
>
@foreach ($getFieldTypes() as $fieldType => $fieldTypeLabel)
<option value="{{ $fieldType }}">{{ $fieldTypeLabel }}</option>
@endforeach
</x-filament-forms::select>
</td>
Want results from more Discord servers?
Add your server