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),
]);
}
}
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),
]);
}
}