-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
- Laravel Version: 9.38.0
- Nova Version: 4.17.1
- PHP Version: 8.1.1
- Database Driver & Version: MariaDB 10.5
- Operating System and Version: Windows 11
- Browser type and version: Google Chrome 106.0.5249.119
- Reproduction Repository: https://github.com/###/###
Description:
When I try create a new register (Asset), the following message is returned: "The Entity field is required.".
Debugging I noticed that Laravel Nova sends the id for validation instead of the code field, which would be correct.
Detailed steps to reproduce the issue on a fresh Nova installation:
- Create a new Asset using Laravel Nova interface
- Configure models and resources as below:
I have a two models, entity and assets:

In my assets Model I've entity method with BelongsTo relationship.
public function entity(): BelongsTo
{
return $this->belongsTo(
Entity::class, // Eloquent model
Asset::ENTITY_CODE, // Foreing key
Entity::CODE, // Owner key
);
}In Entity Resource (Laravel Nova):
public function fields(NovaRequest $request): array
{
return [
ID::make()->sortable(),
Text::make('Code')->hideWhenUpdating()->sortable(),
Text::make('Name')->sortable(),
Text::make('Description')->sortable(),
BelongsTo::make('Entity Code', null, Entity::class)
->dontReorderAssociatables()
->withoutTrashed()
->sortable()
->hideWhenUpdating()
->creationRules('exists:entities,code'),
];
}Metadata
Metadata
Assignees
Labels
No labels