platform icon indicating copy to clipboard operation
platform copied to clipboard

Relation field empty option

Open keasy9 opened this issue 2 months ago • 0 comments

It seems to be impossible to make Relation field nullable (not non-required). If I selected value in it once, there is no way to clear it, even if field not required.

Reproducing:

Relation::make('post.user')
    ->fromModel(User::class, 'name')
    ->title('User')
    ->allowEmpty() // does nothing
    ->empty('-'),  // not works at all, because there is no such method in Relation class

Select::make('post.user')
    ->fromModel(User::class, 'name')
    ->title('User')
    ->empty('-'), // works perfectly

And there is no empty option or other way to clear it without page refreshing:

Image

But there a way to clear simple select since it has empty option:

Image

And also I think that adding method empty instead of allowEmpty to Relation will be more consistent and convenient.

keasy9 avatar Oct 30 '25 09:10 keasy9