How can I add Actions to the body of Sections?

Its all in the title:)
10 Replies
DarkKnight
DarkKnightOP12mo ago
Maybe the best way is to create a view field (custom field) that looks like an action. Right?
awcodes
awcodes12mo ago
Look up anonymous actions in the docs.
DarkKnight
DarkKnightOP12mo ago
Yeah, I looked it up, but I still cant get it right
Section::make('Cache')
->schema([
ViewField::make('clear_cache')
->view('forms.components.clear-cache-field')
->registerActions(
[
Actions::make([
Action::make('star')
->icon('heroicon-m-star')
->requiresConfirmation()
->action(function () {

}),
Action::make('resetStars')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {

}),
]),
]
)
])
Section::make('Cache')
->schema([
ViewField::make('clear_cache')
->view('forms.components.clear-cache-field')
->registerActions(
[
Actions::make([
Action::make('star')
->icon('heroicon-m-star')
->requiresConfirmation()
->action(function () {

}),
Action::make('resetStars')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {

}),
]),
]
)
])
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<x-filament::button>
Test
</x-filament::button>

<!-- {{ $this->getAction('star') }} -->

</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<x-filament::button>
Test
</x-filament::button>

<!-- {{ $this->getAction('star') }} -->

</div>
</x-dynamic-component>
awcodes
awcodes12mo ago
you don't need a view field
DarkKnight
DarkKnightOP12mo ago
OH I see now
awcodes
awcodes12mo ago
Section::make('Cache')
->schema([
Actions::make([
Action::make('star')
->icon('heroicon-m-star')
->requiresConfirmation()
->action(function () {

}),
Action::make('resetStars')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {

}),
]),
])
Section::make('Cache')
->schema([
Actions::make([
Action::make('star')
->icon('heroicon-m-star')
->requiresConfirmation()
->action(function () {

}),
Action::make('resetStars')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {

}),
]),
])
DarkKnight
DarkKnightOP12mo ago
wow yeah, my bad I misunderstood this. Thank you Is it also possible to have widgets/charts inside of Section?
awcodes
awcodes12mo ago
for that you would need a custom component.
awcodes
awcodes12mo ago
Yes.
Want results from more Discord servers?
Add your server