Tables\Columns\Select trigger error on null/placeholder selection
Hello guys,
I would like to report a bug I have found.
I have this Select column in a Resource's table:
Tables\Columns\SelectColumn::make('production_lot_id')
->label('Lot')
->placeholder('N/D')
->options(fn(OrderDetail $record) => ProductionLot::recommendedForOrderDetail($record)->get()->pluck('option_label', 'id',))
->extraAttributes([ 'class' => 'w-[180px] text-xs leading-5 px-1']),
The field "production_lot_id" is a nullable foreign key defined as below:
$table->foreignId('production_lot_id')->nullable()->constrained('production_lots')->onDelete('set null');
When I select the placeholder (null value) I get the alpine error as per the attached screenshot and the update fails because the query is malformed (NULL is missing).
Is there anything which I'm missing or is it a bug?3 Replies
This is a temporary workaround for the issue.
I convert the empty string to null in updateStateUsing().
I think the issue is, that we don't have a
->nullable()
method like we do have for Select
That's a great workaround for the time being