-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, null given #294
Comments
thank you for the report, the PR on the way :) #295 |
i'm sorry to say @atmonshi but the same error also occurs with $newClass->getOptions() in Schemata.php in latest version. (v3.0.56) for each of the Field/Classes/ (TextInput.php for example) you have set: Bolt::getCustomSchema('field', resolve(static::class)) ?? [], but that needs to be changed as well to: ...Bolt::getCustomSchema('field', resolve(static::class)) ?? [], and i think it also has to be added in some other places like: Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::hidden() : [], to be: ...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::hidden() : [], |
I cant reproduce :) I have an app, no bolt pro, and no
but maybe you're right about the can you share the error trace? |
No i don't use CustomSchema. I was referring to Schemata.php in your package. And no I don’t have Bolt Pro. I will share error trace but because it uses Livewire (/update method) I couldn’t see much in the trace-back. So I stepped through the code with Xdebug. |
Here is error trace:
|
So what i mean is that in Schemata.php Line 426 the function $class->getOptions() gets called. $class is new instance of the field_type, for example the TextInput.php class in src/Fields/Classes/TextInput.php but that depends on the type you've added to the form. So as an example I will use the TextIput.php (but it applies to all src/Fiels/Classes/ php classes) : In that Class the function getOptions() creates an Accordion.. but when you do this: Accordions::make('options')
->accordions([
// removed first 2 accordions in this example
// Accordion::make('validation-options')
// Accordion::make('visual-options') ),
self::hintOptions(),
self::visibility($sections),
// @phpstan-ignore-next-line
...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::schema($field) : [],
Bolt::getCustomSchema('field', resolve(static::class)) ?? [],
]), the accordions([.......]) array will have a last item which is an empty array. But ->accordions() function only accepts childs as a So by adding the three dots... the whole item would not get added to the ->accordions([ .......... ]) array. or use the array_filter again on the array ;-) which also filters out the empty values in the array. like so: Accordions::make('options')
->accordions(
array_filter([
// removed first 2 accordions in this example
// Accordion::make('validation-options')
// Accordion::make('visual-options') ),
self::hintOptions(),
self::visibility($sections),
// @phpstan-ignore-next-line
...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::schema($field) : [],
Bolt::getCustomSchema('field', resolve(static::class)) ?? [],
])
), or with the ... dots: Accordions::make('options')
->accordions([
// removed first 2 accordions in this example
// Accordion::make('validation-options')
// Accordion::make('visual-options') ),
self::hintOptions(),
self::visibility($sections),
// @phpstan-ignore-next-line
...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::schema($field) : [],
...Bolt::getCustomSchema('field', resolve(static::class)) ?? [],
]), see: https://www.php.net/manual/en/function.array-filter.php if callback is not used: So than it does not matter if there are [], null or "" items in the array, they will all get removed, as they don't belong there. because in the example here above: ->accordions() only accepts an array of Component(s). |
I'll debug more :) also worth mention this is how accordions works public function accordions(array | Closure $accordions): static
{
if (is_array($accordions)) {
$accordions = array_filter($accordions);
}
$this->childComponents($accordions);
return $this;
} |
Perfect also! You’ve added the array_filter in the accordion() function 👍🏻 |
I need the 3 dots here: coz the I dont need the dots here: coz the I will create a fresh app and test it more tho till I find the issue you got. |
make sure you updated that package too, it could be the issue here? |
I’m at version v3.0.56 |
I haven’t specifically required it in my project. Only Lara-Zeus/bolt and that shows me version:v1.1.3 |
Yes after updating to latest accordion the with array_filter in it everything works as it should. Awesome job! |
ah finally :) |
I think that in bolt package composer.json the lara-zeus/accordion: “^1.0”, Did not upgrade correctly. Not sure why…? |
ya I think it should be: will update it |
Very weird but it’s fixed anyways lara-zeus/bolt/composer.lock file I found lara-zeus/accordion version 1.1.3 |
What happened?
I'm getting this error when editing/adding a form. It looks like it has to do with some Fields:
Checkbox
DateTimePicker
Toggle
DatePicker
RichEditor
TimePicker
Textarea
Paragraph
and specific with the Bolt::hasPro() true/false check --> null
so when i add a field "CheckBoxList" for example, then i receive the error:
After digging some deeper i came out at the function:
when i comment out the line:
that part works and i won't get any error anymore.
So i tried using that return array to be with array_filter(). So that NULL values will be removed.
This helps.
I see a lot of places where Bolt::hasPro() is used and i think because maybe latest filament update cannot handle the null values for the "field Options" in the dialog.
i'm using Filament version: v3.2.85
How to reproduce the bug
update to latest filament and zeus-bolt. create a new form, and add a field with one of the types :
Checkbox
DateTimePicker
Toggle
DatePicker
RichEditor
TimePicker
Textarea
Paragraph
Package Version
3.0.46
PHP Version
8.3.7
Laravel Version
10.48.12
Which operating systems does with happen with?
No response
Notes
No response
The text was updated successfully, but these errors were encountered: