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

lorenzoberti's avatar

Use ONE form for 2 resources

I'm new on Laravel Nova. I'm trying to build a User form. In this moment I have these models: User, UserDetail

In User I have: email, password, username. In UserDetail I have: Name, Lastname, Gender, Number, etc.

Now I would create ONE form for user. Why I'm focusing on ONE? Because in my User Resource fields I have:

HasOne::make("UserDetail", "details")

But For set user detail I have 2 form: One for User data (username, password, email) And after save the user I can set detail.

So I don't want compile 2 different form for 1 resource.

I have found this package, but seems broke:

https://github.com/yassipad/laravel-nova-nested-form/issues/66

And the fields UserDetails doens't shown.

So is there any other way for add text field from relationship and merge in same Form?

0 likes
8 replies
lorenzoberti's avatar

Because I would like use a Default Laravel Nova behavior (resources and Models) for save, update, delete. if I have to write/override these I would buy an pure html/css theme.

1 like
steve_laracasts's avatar

I don't know Nova at all really, but my eyes widened in surprise when I saw this and I had to go and look at the docs. There's full support for all relationship types in Laravel so the front end you are developing should be written as suggested by @mstrauss

From the docs:

In addition to the variety of fields we've already discussed, Nova has full support for all of Laravel's relationships. Once you add relationship fields to your Nova resources, you'll start to experience the full power of the Nova dashboard, as the resource detail screen will allow you to quickly view and search a resource's related models

Is this not what you want?

lorenzoberti's avatar

Hello thankyou, Yes Nova has full support for Relationship but... If I use a Hasone relationship for create a Form, with 2 Model connected, I should firstly , create a model and then add data for second model, so 2 form.

Immagine now, that you would like create a User form where You have to set Username, password, email, name, lastname, phone and others data relative to USERDETAIL model. You should create user (with username password email) save, and then go on the other page with the form with the user details.

And now I've found this issue that confirm my doubt:

https://github.com/laravel/nova-issues/issues/777

1 like
steve_laracasts's avatar

I see, that's interesting and yes, I agree, it should probably be changed for this use case.

Thanks for coming back and updating this thread with this answer will probably help me and others in the future :)

swiftroot's avatar

Has there been any more work on this? I'm also new to Nova and have not explored this in detail, however, this is a very common use case. E-Commerce is another example where, when creating a main product, you might want to create variations on the same page.

1 like
kuamatzin's avatar

I have do it at route level.

First you need to identify the route your resource is using, for example, to override the create method from the resource Post, the route will be something like (you can use artisan route:list):

/nova-api/posts.

Then in your web.php file override the route, but here is the important part, you need to add the Nova middleware to add the security rules from Nova. You can group all the routes that you need to override:

// Override Nova Routes  
Route::middleware(config('nova.middleware'))->group(function () {  
 Route::post('/nova-api/posts', 'PostController@myCustomFunctionForCreateNovaResource');  
});
2 likes

Please or to participate in this conversation.