|
3 | 3 | namespace MailCarrier\Resources;
|
4 | 4 |
|
5 | 5 | use Filament\Forms;
|
| 6 | +use Filament\Forms\Components\Grid; |
6 | 7 | use Filament\Forms\Form;
|
7 | 8 | use Filament\Resources\Resource;
|
8 | 9 | use Filament\Tables;
|
@@ -139,35 +140,50 @@ protected static function getTableFilters(): array
|
139 | 140 | /**
|
140 | 141 | * Get the form content.
|
141 | 142 | */
|
142 |
| - protected static function getFormContent(): Forms\Components\Section |
| 143 | + protected static function getFormContent(): Forms\Components\Grid |
143 | 144 | {
|
144 |
| - return Forms\Components\Section::make([ |
145 |
| - Forms\Components\TextInput::make('name') |
146 |
| - ->label('Internal name') |
147 |
| - ->required() |
148 |
| - ->autofocus() |
149 |
| - ->columnSpanFull() |
150 |
| - // Disable field UI if the record exists and user can't unlock it |
151 |
| - ->disabled(fn (?Template $record) => !is_null($record) && $record->is_locked) |
152 |
| - // Save the field if record does not exist or user can unlock it |
153 |
| - ->dehydrated(fn (?Template $record) => is_null($record) || !$record->is_locked), |
154 |
| - |
155 |
| - Forms\Components\TextInput::make('slug') |
156 |
| - ->label('Unique identifier (slug)') |
157 |
| - ->placeholder('Leave empty to auto generate') |
158 |
| - ->helperText(new HtmlString('<span class="text-xs text-slate-500 pl-2">Use this as "template" key in your APIs</span>')) |
159 |
| - ->columnSpanFull() |
160 |
| - ->required(fn (?Template $record) => !is_null($record)) |
161 |
| - // Disable field UI if the record exists and user can't unlock it |
162 |
| - ->disabled(fn (?Template $record) => !is_null($record) && $record->is_locked) |
163 |
| - // Save the field if record does not exist or user can unlock it |
164 |
| - ->dehydrated(fn (?Template $record) => is_null($record) || !$record->is_locked) |
165 |
| - ->extraInputAttributes([ |
166 |
| - 'onClick' => 'this.select()', |
| 145 | + return Grid::make(1) |
| 146 | + ->schema([ |
| 147 | + Forms\Components\Section::make([ |
| 148 | + Forms\Components\TextInput::make('name') |
| 149 | + ->label('Internal name') |
| 150 | + ->required() |
| 151 | + ->autofocus() |
| 152 | + ->columnSpanFull() |
| 153 | + // Disable field UI if the record exists and user can't unlock it |
| 154 | + ->disabled(fn (?Template $record) => !is_null($record) && $record->is_locked) |
| 155 | + // Save the field if record does not exist or user can unlock it |
| 156 | + ->dehydrated(fn (?Template $record) => is_null($record) || !$record->is_locked), |
| 157 | + |
| 158 | + Forms\Components\TextInput::make('slug') |
| 159 | + ->label('Unique identifier (slug)') |
| 160 | + ->placeholder('Leave empty to auto generate') |
| 161 | + ->helperText('Use this as "template" key in your APIs') |
| 162 | + ->columnSpanFull() |
| 163 | + ->required(fn (?Template $record) => !is_null($record)) |
| 164 | + // Disable field UI if the record exists and user can't unlock it |
| 165 | + ->disabled(fn (?Template $record) => !is_null($record) && $record->is_locked) |
| 166 | + // Save the field if record does not exist or user can unlock it |
| 167 | + ->dehydrated(fn (?Template $record) => is_null($record) || !$record->is_locked) |
| 168 | + ->extraInputAttributes([ |
| 169 | + 'onClick' => 'this.select()', |
| 170 | + ]), |
| 171 | + |
| 172 | + static::getFormEditor(), |
167 | 173 | ]),
|
168 | 174 |
|
169 |
| - static::getFormEditor(), |
170 |
| - ]); |
| 175 | + Forms\Components\Section::make([ |
| 176 | + Forms\Components\Textarea::make('description') |
| 177 | + ->label('Description') |
| 178 | + ->helperText('A short description of the template, visible only in the admin area') |
| 179 | + ->placeholder('How is this template being used? What\'s the purpose?') |
| 180 | + ->columnSpanFull() |
| 181 | + // Disable field UI if the record exists and user can't unlock it |
| 182 | + ->disabled(fn (?Template $record) => !is_null($record) && $record->is_locked) |
| 183 | + // Save the field if record does not exist or user can unlock it |
| 184 | + ->dehydrated(fn (?Template $record) => is_null($record) || !$record->is_locked), |
| 185 | + ]), |
| 186 | + ]); |
171 | 187 | }
|
172 | 188 |
|
173 | 189 | /**
|
|
0 commit comments