Display Cards under Select
Within a Wizard I'm trying to display the selected items in a custom card but I keep getting Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization, how do I solve this?
This is Laravel 12 with Filament 3.x. My code is too long to include in this message I can share it in the comments.
11 Replies
Share the relevant code. Select and the "card"
This is the step within the Wizard
this is the card
the imports are there but I took them out of this message because of the character limit
I guess this part could be the issue:
->schema(function ($get) {
Could you test, whether 1 static card does work?static card with dummy data or what? the idea is that when a user selects an Employee, the selected employee(s) appear in cards. I thought I would be able to set some sort of state so every time an employee is selected it gets pushed into an array and as long as they array is populated, we can map over it and display a card per employee.
Static card like:
(also, thank you so much for your time/help)
Just trying to simplify the problem to find the source of the issue
a static card throws the same error:
the error points to the ->state() line
I must be missing something fundamental but I don't know what I don't know and am not sure how to look it up
Ah makes sense. I don't think you can set the state before the component is initialised
I'd probably refactor this into a single ViewField that just uses
$get('selected_employees')
, runs the DB query and loops over them.
I don't think state()
should be called from user land
You could try replacing ->state()
with ->getStateUsing(fn () => )
the context is there is an Account and now we're adding Employees to the account. When selecting an employee to be added, we want to display the cards. So when viewing in edit mode, we could have the ViewField query and iterate. But when adding in real time, we just want to use local state because the employees aren't really added to the account until the user clicks "save" on this step of the wizard.
I ended up using a Placeholder component with custom HTML rendered for each item in the list, ditching the idea of using a component for each item. This seems to be working!