This commit is contained in:
Dan Harrin
2023-11-20 10:02:08 +00:00
parent b13e144380
commit a9a3490fc5
6 changed files with 44 additions and 18 deletions
+17 -2
View File
@@ -32,9 +32,9 @@ Section::make()
<AutoScreenshot name="forms/layout/section/without-header" alt="Section without header" version="3.x" />
## Adding action to the section's header
## Adding actions to the section's header
You may add action to the section's header using the `headerAction` or `headerActions()` method:
You may add [actions](../actions) to the section's header using the `headerActions()` method:
```php
use Filament\Forms\Components\Actions\Action;
@@ -54,6 +54,21 @@ Section::make('Address')
<AutoScreenshot name="forms/layout/section/actions" alt="Section with header actions" version="3.x" />
If your section does not have a heading, Filament has no way of locating the action inside it. In this case, you must pass a unique `id()` to the section:
```php
use Filament\Forms\Components\Section;
Section::make()
->id('addressSection')
->headerActions([
// ...
])
->schema([
// ...
])
```
## Adding an icon to the section's header
You may add an [icon](https://blade-ui-kit.com/blade-icons?set=1#search) to the section's header using the `icon()` method:
@@ -19,13 +19,6 @@ trait HasHeaderActions
*/
protected array $headerActions = [];
public function headerAction(Action | Closure $action): static
{
$this->headerActions([$action]);
return $this;
}
/**
* @param array<Action | Closure> $actions
*/
@@ -91,6 +91,11 @@ class Section extends Component implements Contracts\CanConcealComponents, Contr
return $id;
}
public function getKey(): ?string
{
return parent::getKey() ?? $this->getId();
}
public function canConcealComponents(): bool
{
return $this->isCollapsible();
@@ -32,9 +32,9 @@ Section::make()
<AutoScreenshot name="infolists/layout/section/without-header" alt="Section without header" version="3.x" />
## Adding action to the section's header
## Adding actions to the section's header
You may add action to the section's header using the `headerAction` or `headerActions()` method:
You may add [actions](../actions) to the section's header using the `headerActions()` method:
```php
use Filament\Infolists\Components\Actions\Action;
@@ -54,6 +54,21 @@ Section::make('Address')
<AutoScreenshot name="infolists/layout/section/actions" alt="Section with header actions" version="3.x" />
If your section does not have a heading, Filament has no way of locating the action inside it. In this case, you must pass a unique `id()` to the section:
```php
use Filament\Infolists\Components\Section;
Section::make()
->id('addressSection')
->headerActions([
// ...
])
->schema([
// ...
])
```
## Adding an icon to the section's header
You may add an icon to the section's header using the `icon()` method:
@@ -19,13 +19,6 @@ trait HasHeaderActions
*/
protected array $headerActions = [];
public function headerAction(Action | Closure $action): static
{
$this->headerActions([$action]);
return $this;
}
/**
* @param array<Action | Closure> $actions
*/
@@ -91,6 +91,11 @@ class Section extends Component implements Contracts\HasHeaderActions
return $id;
}
public function getKey(): ?string
{
return parent::getKey() ?? $this->getId();
}
public function isAside(): bool
{
return (bool) ($this->evaluate($this->isAside) ?? false);