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

an.leclerc's avatar

Save form into another form

Hi,

I have a question, is it possible to save child form into parent form ?

I have a user_form, inside this form, I put address_form.

In my database user has a column named "address_id".

What is the best way to save the user and address and fill in the address_id with the new address that has just been saved ?

0 likes
4 replies
tangtang's avatar

yes, you can do something like that. but why make it complicated?

an.leclerc's avatar

address_form is inside another component.

When I save user_form, I dispatch a event to address_form to save new address and update user with address_id and it works perfectly, but after saving, I redirect to another page and on this page address_id is null until I refresh the page.

an.leclerc's avatar

I did not use controller, only livewire component/form.

I put address form fields into user form, modify my component and it works well. But ideally I'd like to create a reusable component Address.

Jsanwo64's avatar

Why not try to save the first and if input is validated, save either to cache then hide the first form to show the second form use if/else

Please or to participate in this conversation.