Setting Prebuilt Blocks (Template) into the PageBuilder #84
-
I have a Template Module that uses the FilamentFabricator Package to pre-arrange different page blocks into a template that can be reused several times in the PageResource. I do this by Using a select field which has a list of the templates to set the 'blocks' PageBuilder field. This works perfectly until i load a template that uses a file upload component or a Package called FilamentCurator, then it throws this error "foreach() argument must be of type array|object, string given" or "count(): Argument #1 ($value) must be of type Countable|array, int given". Please help out with this. Below is a code snippet of the PageResource and how i use the template
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't think you can use ->afterStateUpdated(function ($state, $livewire) {
if(blank($state)) {
$blocks = null;
} else {
$template = Template::find($state);
$blocks = $template->blocks;
}
$newState = [
...$livewire->form->getRawState(),
'blocks' => $blocks,
];
$livewire->form->fill($newState);
}) |
Beta Was this translation helpful? Give feedback.
I don't think you can use
$set
directly on a FileUpload input. Instead try something like this: