0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Filament 2.x】自動生成される作成ボタンの大きさを変更する

Last updated at Posted at 2023-05-16

概要

デフォルトのボタンの大きさはこんな感じになってますよね。

スクリーンショット 2023-05-16 12.00.28.png

ドキュメント曰く->size('lg')メソッドでアクションボタンの大きさを変更するらしいですが

作成ボタンのアクションは継承元のCreateRecordクラスのgetCreateFormActionで定義されてるのでオーバーライドして追記します。

app/Filament/Resources/StoreResource/Pages/CreateStore.php
class CreateStore extends CreateRecord
{
    protected static string $resource = StoreResource::class;

    protected function getCreateFormAction(): Action
    {
        return Action::make('create')
            ->label(__('Create'))
            ->submit('create')
            ->keyBindings(['mod+s'])
            ->size('lg');
    }
}

image.png

はいでかくなりました。

一覧ページの「作成」ボタンをでかくする

アクションを生成している処理があるのでsize()を付け足します

app/Filament/Resources/StoreResource/Pages/ListStores.php
class ListStores extends ListRecords
{
    protected static string $resource = StoreResource::class;

    protected function getActions(): array
    {
        return [
            Actions\CreateAction::make()->size('lg'),
        ];
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?