Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mic2100's avatar

Required field issues

Hi,

I'm having some problems with Laravel Nova 4.

I have a table with a nullable column to store an extension ID. This is optional which is why it is nullable.

The models method is like

    public function extension(): BelongsTo
    {
        return $this->belongsTo(Model\Detail::class, 'extension_id', 'id');
    }

and in the nova resource class it looks like this

Fields\BelongsTo::make('Extension Details', 'extension', Nova\Detail::class)->searchable()->required(false)

When I try to save the resource without selecting an extension it get an error to indicate that the field is required (the red "validation.required" text shows), even though the red star to indicate required fields is not visible.

Without the ->required(false) the red star shows and same validation error.

Is there any reason I cannot used a belongsTo field that is nullable?

0 likes
2 replies
mic2100's avatar

Wow! I can't believe I missed that!

Adding ->nullable() to the resource seems to have done the trick

Thanks Nakov :)

Please or to participate in this conversation.