You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fields.md
+124-3Lines changed: 124 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -227,6 +227,19 @@ $field->max('2024-01-01');
227
227
$field->max(now()->addDays(7));
228
228
```
229
229
230
+
### Dropdown
231
+
232
+
The `Dropdown` field is turbo-charded version of the [`Select`](#select) field. You may checkout its documentation.
233
+
234
+
```php
235
+
$field = Dropdown::make(__('Tags'), 'tags')
236
+
->options([
237
+
'bug' => 'Bug',
238
+
'info' => 'Info',
239
+
'question' => 'Question',
240
+
]);
241
+
```
242
+
230
243
### Editor
231
244
232
245
The `Editor` field is typically a handler for `text` model attributes (HTML). The `Editor` field is a [Tiptap](https://tiptap.dev/product/editor) editor combined with [alpine](https://alpinejs.dev/):
@@ -263,20 +276,116 @@ You can also apply modifiers on a `Editor` field:
263
276
$field->height('300px');
264
277
```
265
278
266
-
### File
279
+
### Email
280
+
281
+
The `Email` field is typically a handler for `email` model attributes:
The `Hidden` field is eqvivalent to a simple `Field` instance, however it automatically gets a `type="hidden"` HTML attribute, that makes it uneditable:
306
+
307
+
```php
308
+
$field = Hidden::make(__('Token'), 'token')
309
+
->default(fn (): string => Str::uuid());
310
+
```
267
311
268
312
### ID
269
313
270
-
### Media
314
+
The `ID` field is typically a handler for the model's primary key. It can be an incremental numeric ID or a UUID as well.
315
+
316
+
```php
317
+
$field = ID::make();
318
+
```
271
319
272
320
### Number
273
321
322
+
The `Number` field is typically a handler for `numeric` model attributes:
323
+
324
+
```php
325
+
$field = Number::make(__('Age'), 'age');
326
+
```
327
+
328
+
You can also apply modifiers on a text field:
329
+
330
+
```php
331
+
// Adds the "size" HTML input attribute
332
+
$field->size(40);
333
+
334
+
// Adds the "min" HTML input attribute
335
+
$field->min(40);
336
+
337
+
// Adds the "max" HTML input attribute
338
+
$field->max(40);
339
+
340
+
// Adds the "step" HTML input attribute
341
+
$field->step(1);
342
+
```
343
+
274
344
### Radio
275
345
346
+
The `Radio` field is similar to [`Checkbox`](#checkbox), however only single values are allowed, unlike in the case of `Checkbox`, where array of values are being stored:
347
+
348
+
```php
349
+
$field = Radio::make(__('Role'), 'role')
350
+
->options([
351
+
'admin' => 'Admin',
352
+
'editor' => 'Editor',
353
+
'member' => 'Member',
354
+
]);
355
+
```
356
+
357
+
You may also pass a `Closure` to customize the resolution logic of the options:
358
+
359
+
```php
360
+
use App\Category;
361
+
use Illuminate\Database\Eloquent\Model;
362
+
use Illuminate\Http\Request;
363
+
364
+
$field = Radio::make(__('Category'), 'category')
365
+
->options(static function (Request $request, Model $model): array {
The `Range` field is typically a handler for `numeric` model attributes:
376
+
377
+
```php
378
+
$field = Range::make(__('Points'), 'points')
379
+
->min(0)
380
+
->max(10);
381
+
```
382
+
383
+
### Repeater
384
+
278
385
### Select
279
386
387
+
### Slug
388
+
280
389
### Tag
281
390
282
391
### Text
@@ -287,7 +396,7 @@ The `Text` field is typically a handler for `string` model attributes:
287
396
$field = Text::make(__('Title'), 'title');
288
397
```
289
398
290
-
You can also apply modifiers on a text field:
399
+
You can also apply modifiers on `Text` field:
291
400
292
401
```php
293
402
// Adds the "size" HTML input attribute
@@ -318,6 +427,8 @@ $field->rows(20);
318
427
$field->cols(100);
319
428
```
320
429
430
+
### URL
431
+
321
432
### Relation Fields
322
433
323
434
Relation fields are representing Eloquent relation definitions on the resource models. Relation fields are highly customizable and provide a nice and detailed API.
0 commit comments