Livewire form field not included in parent form's data

Hi, I have a big form with several repeaters, and each repeater has several fields, and it's got so big that, whenever an update occurs, it takes up to 2 seconds. I have moved the repeaters into individual Livewire component fields. The issue I'm having is that the data is not accessible from the main form upon submission. To simplify the question, I'm going to use this test form:
public function form(Form $form): Form
{
return $form->schema([
Forms\Components\TextInput::make('name'),
Forms\Components\Livewire::make(NestedField::class),
]);
}
public function form(Form $form): Form
{
return $form->schema([
Forms\Components\TextInput::make('name'),
Forms\Components\Livewire::make(NestedField::class),
]);
}
And this Livewire component:
class NestedField extends Component implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('nested_input'),
])
->statePath('data');
}
class NestedField extends Component implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('nested_input'),
])
->statePath('data');
}
.... I'm rendering both blades with {{ $this->form }}. The result of this code is that both fields get rendered correctly within the same form, their wire:model are: 'data.name' and 'data.nested_input', BUT upon submission, only 'name' is received:
array:1 [
"name" => "Demo name"
]
array:1 [
"name" => "Demo name"
]
I've been playing around with ->statePath in different places and things like that but I had no luck. Does anyone know if this is possible at all? Alternatively I would want to fetch both forms on submission and merge them. Thanks
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?