Form Wizard and Dynamic Fill?

Radio::make('moveOrMerge')
->options([
'move' => 'Move',
'merge' => 'Merge',
])
->required(),
Select::make('merge_target')
->options(function () use ($table) {
if (isset($this->target_tenant_options)) {
return $this->target_tenant_options[$table] ?? [];
}

return [];
})
->required(function (Get $get) {
if ($get('moveOrMerge') === 'merge') {
return true;
}

return false;
}),
Radio::make('moveOrMerge')
->options([
'move' => 'Move',
'merge' => 'Merge',
])
->required(),
Select::make('merge_target')
->options(function () use ($table) {
if (isset($this->target_tenant_options)) {
return $this->target_tenant_options[$table] ?? [];
}

return [];
})
->required(function (Get $get) {
if ($get('moveOrMerge') === 'merge') {
return true;
}

return false;
}),
why does something simple like this on a required() logic create Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization? I even get this error when I am on step 1 of the wizard and this field is in step 2
7 Replies
Mark Chaney
Mark ChaneyOP13mo ago
Anyone have any suggestions? I wonder if using assigning data using $this->data for some of the wizard steps is causing issues with $get giving this error. IM doing
])->afterValidation(function ($state) {
$this->source_tenant_id = $state['source_tenant_id'];
$this->target_tenant_id = $state['target_tenant_id'];
$this->fillForm();
});
])->afterValidation(function ($state) {
$this->source_tenant_id = $state['source_tenant_id'];
$this->target_tenant_id = $state['target_tenant_id'];
$this->fillForm();
});
after the first step of the wizrd to dynamically fill the rest of the data for the other steps. Then at the end of that filleForm(), im doing
$this->data[$table] = $preparedData;
$this->data[$table] = $preparedData;
awsqed
awsqed13mo ago
does it make any differences when you comment out this part
if (isset($this->target_tenant_options)) {
return $this->target_tenant_options[$table] ?? [];
}
if (isset($this->target_tenant_options)) {
return $this->target_tenant_options[$table] ?? [];
}
Mark Chaney
Mark ChaneyOP13mo ago
@awsqed no difference found out its a bug with the tablerepeater. got it solved. woo hoo
veronica17(ale)
veronica17(ale)13mo ago
how did you solve it? im having the same issue 😧
Mark Chaney
Mark ChaneyOP13mo ago
@veronica17(ale) im locked into an older verison of table repeater, so i had to create my own tablerepeater class an extend it with the change. I changed line 86 to foreach ($this->getChildComponentContainer()->getComponents() as $field) in the getHeaders() method. Again, this is specific to the tablerepeater package. Not sure if adam already has it fixed in a newer version
veronica17(ale)
veronica17(ale)13mo ago
thanks im using https://filamentphp.com/plugins/icetalker-table-repeater plugin and im not sure where the bug is
Filament
Table Repeater by Martin Hwang - Filament
Filament Repeater display in table layout.
Mark Chaney
Mark ChaneyOP13mo ago
@veronica17(ale) oh, i only use awcodes @veronica17(ale) i would only recommend https://github.com/awcodes/filament-table-repeater. Should be a fairly painless swap for you
Want results from more Discord servers?
Add your server