Can't `$this->form->fill()` images in custom Livewire Page while using Repeater

in my
public function mount(): void
public function mount(): void
i'm trying to fill app_intro_image's in app_screens
$this->form->fill([
'app_home_page_order' => json_decode($this->user-
>getAppSetting('app_home_page_order'), true),
'app_general_title' => $this->user->getAppSetting('app_general_title'),
'app_screens' => $appScreens,
]);
$this->form->fill([
'app_home_page_order' => json_decode($this->user-
>getAppSetting('app_home_page_order'), true),
'app_general_title' => $this->user->getAppSetting('app_general_title'),
'app_screens' => $appScreens,
]);
output data that is being filled.
array:3 [// app/Filament/AppPanel/Pages/AppSettings.php:76
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
0 => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => "http://myapp.test/storage/16/appify-logo-white.svg"
]
]
]
array:3 [// app/Filament/AppPanel/Pages/AppSettings.php:76
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
0 => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => "http://myapp.test/storage/16/appify-logo-white.svg"
]
]
]
Here is what my data state looks like after page is rendered on browser.
+data: array:3 [
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
"2f70d635-e64f-4f7c-832b-67cf019dec2e" => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => []
]
]
]
+data: array:3 [
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
"2f70d635-e64f-4f7c-832b-67cf019dec2e" => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => []
]
]
]
http://myapp.test/storage/16/appify-logo-white.svg perfectly accesible from browser. Context i have been experiencing same issue for a year now here is - reproducible repo https://github.com/RizwanNaasir/filament-form-issue and related issue that was closed without any further solution. - https://github.com/filamentphp/filament/issues/5441
GitHub
GitHub - RizwanNaasir/filament-form-issue
Contribute to RizwanNaasir/filament-form-issue development by creating an account on GitHub.
GitHub
Fileupload Component of Filament/Forms cannot be filled with images...
Package filament/forms Package Version v2.16 Laravel Version v9.46 Livewire Version v2.10.8 PHP Version PHP 8.1 Problem description This Repo contains minimal reproduction of issue in Filament/Form...
No description
Solution:
I was missing call to my actual ->model() instance on SpatieMediaLibraryFileUpload componet. e.g ```php...
Jump to solution
5 Replies
KA
KA12mo ago
your reproduction repo is using "filament/forms": "^2.16", but you tagged v3
RizwanNasir
RizwanNasirOP12mo ago
becuse this issue still uccoring to this date since in v2 and now in v3. @KA did you ever encounter this issue while using form builder this way ?
Lara Zeus
Lara Zeus12mo ago
repeater accept array of arrays and the key has to be string you can use Str::Uuid()
RizwanNasir
RizwanNasirOP12mo ago
@Lara Zeus after rendered the public array $data does contain auto generated uuid for the keys of repeater childeren.
+data: array:3 [
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
"2f70d635-e64f-4f7c-832b-67cf019dec2e" => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => []
]
]
]
+data: array:3 [
"app_home_page_order" => array:2 []
"app_general_title" => "Stack App"
"app_screens" => array:1 [
"2f70d635-e64f-4f7c-832b-67cf019dec2e" => array:4 [
"app_intro_id" => "f8dff274-3408-4d7a-a359-0e4cac89b0e4"
"app_intro_title" => "1st new"
"app_intro_description" => "Nice Feature"
"app_intro_image" => []
]
]
]
Solution
RizwanNasir
RizwanNasir12mo ago
I was missing call to my actual ->model() instance on SpatieMediaLibraryFileUpload componet. e.g
SpatieMediaLibraryFileUpload::make('app_intro_image')
->collection('my-collection')
->hiddenLabel()
->columnSpan(2)
->required()
->model($this->appIntro'),
SpatieMediaLibraryFileUpload::make('app_intro_image')
->collection('my-collection')
->hiddenLabel()
->columnSpan(2)
->required()
->model($this->appIntro'),
Want results from more Discord servers?
Add your server