Skip to content

Relation field empty option #3054

@keasy9

Description

@keasy9

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions