skip to Main Content

Below is my code for creating a modal form. How can I customize its width? I’d like to be a bit smaller

->createOptionForm([
                        FormsComponentsTextInput::make('name')
                            ->required()
                            ->maxLength(255)
                            ->unique(modifyRuleUsing: function (Unique $rule) {
                                return $rule->where('user_id', auth()->id());
                            }),
                        FormsComponentsTextInput::make('stock')
                            ->required()
                            ->integer()
                            ->minValue(1)
                            ->maxLength(255),
                    ])

2

Answers


  1. You can use grid that gives ability to create column(s) inside it

    Grid::make(8)->schema([
                            FormsComponentsTextInput::make('name')
                                ->required()
                                ->maxLength(255)
                                ->unique(modifyRuleUsing: function (Unique $rule) {
                                    return $rule->where('user_id', auth()->id());
                                })
                                ->columnSpan(4),
                            FormsComponentsTextInput::make('stock')
                                ->required()
                                ->integer()
                                ->minValue(1)
                                ->maxLength(255)
                                ->columnSpan(4),
                        ])
    

    For details; https://filamentphp.com/docs/3.x/forms/layout/grid

    Login or Signup to reply.
  2. If the PR I made is accepted, you can do it this way:

    ->createOptionModalWidth(FilamentSupportEnumsMaxWidth::ExtraSmall)
    

    * I’ll update the answer when the PR is accepted and/or this is added to the documentation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search