© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
trovster

Extend Component, set optional schema based on flag

I have moved complex schema sections to new classes, which I then include in the resource. In the extended component I set up the schema for fields. This works nicely and I am able to override things such as the heading that was set in the custom component.

I can't work out how to conditionally make visible/hidden components.

```php
// In the resource I want MyCustomSection::make()->heading('Example')->simple();

class MyCustomSection extends Section
{
protected bool $simple = false;

public function simple()
{
$this->simple = true;
}

protected function setUp(): void
{
parent::setUp();

$this
->heading(class_basename(static::class))
->schema([
... //more fields
DatePicker::make('modified')->hidden($this->simple),
]);
}
}
Solution
I moved the check to
afterStateHydrated
afterStateHydrated
and it worked. 🙂
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Set visibility of component based on current resource
FilamentFFilament / ❓┊help
12mo ago
Placeholder content based on conditional logic based on value from another component?
FilamentFFilament / ❓┊help
3y ago
I want to set form schema columns() based on instance of createUser but it doesnt accept
FilamentFFilament / ❓┊help
15mo ago
Set up Role Based Access Control
FilamentFFilament / ❓┊help
16mo ago