mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge branch '3.x' into more-action-group-improvements
This commit is contained in:
Generated
+7
@@ -15,6 +15,7 @@
|
||||
"@ryangjchandler/alpine-tooltip": "^1.2.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"alpine-lazy-load-assets": "^1.0.5",
|
||||
"alpinejs": "^3.10.4",
|
||||
"async-alpine": "^1.0.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
@@ -3016,6 +3017,12 @@
|
||||
"ajv": "^6.9.1"
|
||||
}
|
||||
},
|
||||
"node_modules/alpine-lazy-load-assets": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/alpine-lazy-load-assets/-/alpine-lazy-load-assets-1.0.5.tgz",
|
||||
"integrity": "sha512-2FiBjxDeyFGRfevBfnI5d8cv7djYQUXLV8GfHVhFoCFLGSLlZmgKXjIBPkJDZvdjmTa4ljtiOAq4EFQEsICEzg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/alpinejs": {
|
||||
"version": "3.12.1",
|
||||
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.12.1.tgz",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"@ryangjchandler/alpine-tooltip": "^1.2.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"alpine-lazy-load-assets": "^1.0.5",
|
||||
"alpinejs": "^3.10.4",
|
||||
"async-alpine": "^1.0.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
|
||||
@@ -106,4 +106,18 @@ Filament includes several prebuilt actions that you can add to your app. Their a
|
||||
- [Delete](prebuilt-actions/delete)
|
||||
- [Replicate](prebuilt-actions/replicate)
|
||||
- [Force-delete](prebuilt-actions/force-delete)
|
||||
- [Restore](prebuilt-actions/restore)
|
||||
- [Restore](prebuilt-actions/restore)
|
||||
|
||||
## Grouping actions
|
||||
|
||||
You may group actions together into a dropdown menu by using an `ActionGroup` object. Groups may contain many actions, or other groups:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
Action::make('view'),
|
||||
Action::make('edit'),
|
||||
Action::make('delete'),
|
||||
])
|
||||
```
|
||||
|
||||
To learn about how to group actions, see the [Grouping actions](grouping-actions) page.
|
||||
|
||||
@@ -41,6 +41,17 @@ Action::make('edit')
|
||||
|
||||
<AutoScreenshot name="actions/trigger-button/icon-button" alt="Icon button trigger" version="3.x" />
|
||||
|
||||
### Using an icon button on mobile devices only
|
||||
|
||||
You may want to use a button style with a label on desktop, but remove the label on mobile. This will transform it into an icon button. You can do this with the `labeledFrom()` method, passing in the responsive [breakpoint](https://tailwindcss.com/docs/responsive-design#overview) at which you want the label to be added to the button:
|
||||
|
||||
```php
|
||||
Action::make('edit')
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->button()
|
||||
->labeledFrom('md')
|
||||
```
|
||||
|
||||
## Setting a label
|
||||
|
||||
By default, the label of the trigger button is generated from its name. You may customize this using the `label()` method:
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
title: Grouping actions
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
You may group actions together into a dropdown menu by using an `ActionGroup` object. Groups may contain many actions, or other groups:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
Action::make('view'),
|
||||
Action::make('edit'),
|
||||
Action::make('delete'),
|
||||
])
|
||||
```
|
||||
|
||||
This page is about customizing the look of the group's trigger button and dropdown.
|
||||
|
||||
## Customizing the group trigger style
|
||||
|
||||
The button which opens the dropdown may be customized in the same way as a normal action. [All of the methods available for trigger buttons](trigger-button) may be used to customize the group trigger button:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])
|
||||
->label('More actions')
|
||||
->icon('heroicon-m-ellipsis-vertical')
|
||||
->size('sm')
|
||||
->color('primary')
|
||||
->button()
|
||||
```
|
||||
|
||||
## Setting the placement of the dropdown
|
||||
|
||||
The dropdown may be positioned relative to the trigger button by using the `placement()` method:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])
|
||||
->placement('bottom-start')
|
||||
```
|
||||
|
||||
## Adding dividers between actions
|
||||
|
||||
You may add dividers between each action in the dropdown by using the `divided()` method:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])
|
||||
->divided()
|
||||
```
|
||||
|
||||
If you'd like to group multiple actions together within one division, you may nest another `ActionGroup` within the main `ActionGroup`, and disable the dropdown on the nested group using `dropdown(false)`:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of individually divided actions
|
||||
ActionGroup::make([
|
||||
// Array of actions within one division
|
||||
])->dropdown(false),
|
||||
// Array of individually divided actions
|
||||
])
|
||||
->divided()
|
||||
```
|
||||
|
||||
## Setting the width of the dropdown
|
||||
|
||||
The dropdown may be set to a width by using the `width()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl` and `7xl`:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])
|
||||
->width('xs')
|
||||
```
|
||||
|
||||
## Controlling the maximum height of the dropdown
|
||||
|
||||
The dropdown content can have a maximum height using the `maxHeight()` method, so that it scrolls. You can pass a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length):
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])
|
||||
->maxHeight('400px')
|
||||
```
|
||||
+4
-4
@@ -93,9 +93,9 @@ public function deleteAction(): Action
|
||||
}
|
||||
```
|
||||
|
||||
## Grouping actions
|
||||
## Grouping actions in a Livewire view
|
||||
|
||||
You may group actions together into a dropdown menu by using the `<x-filament-actions::group>` Blade component, passing in the `actions` array as an attribute:
|
||||
You may [group actions together into a dropdown menu](grouping-actions) by using the `<x-filament-actions::group>` Blade component, passing in the `actions` array as an attribute:
|
||||
|
||||
```blade
|
||||
<div>
|
||||
@@ -109,7 +109,7 @@ You may group actions together into a dropdown menu by using the `<x-filament-ac
|
||||
</div>
|
||||
```
|
||||
|
||||
You can also pass in a `label`, `icon`, `color`, `size`, `tooltip`, and `dropdown-placement` to the group, as attributes:
|
||||
You can also pass in any attributes to customize the appearance of the trigger button and dropdown:
|
||||
|
||||
```blade
|
||||
<div>
|
||||
@@ -129,4 +129,4 @@ You can also pass in a `label`, `icon`, `color`, `size`, `tooltip`, and `dropdow
|
||||
|
||||
<x-filament-actions::modals />
|
||||
</div>
|
||||
```
|
||||
```
|
||||
@@ -2,6 +2,7 @@
|
||||
'actions' => [],
|
||||
'button' => false,
|
||||
'color' => null,
|
||||
'divided' => false,
|
||||
'dropdownPlacement' => null,
|
||||
'dynamicComponent' => null,
|
||||
'group' => null,
|
||||
@@ -20,6 +21,7 @@
|
||||
@php
|
||||
$group = \Filament\Actions\ActionGroup::make($actions)
|
||||
->color($color)
|
||||
->divided($divided)
|
||||
->dropdownPlacement($dropdownPlacement)
|
||||
->icon($icon)
|
||||
->indicator($indicator)
|
||||
|
||||
@@ -16,7 +16,7 @@ Filament includes several [dedicated validation methods](#available-rules), but
|
||||
|
||||
### Active URL
|
||||
|
||||
The field must have a valid A or AAAA record according to the `dns_get_record()` PHP function. [See the Laravel documentation](https://laravel.com/docs/validation#rule-active-url)
|
||||
The field must have a valid A or AAAA record according to the `dns_get_record()` PHP function. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-active-url)
|
||||
|
||||
```php
|
||||
Field::make('name')->activeUrl()
|
||||
@@ -24,7 +24,7 @@ Field::make('name')->activeUrl()
|
||||
|
||||
### After (date)
|
||||
|
||||
The field value must be a value after a given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-after)
|
||||
The field value must be a value after a given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-after)
|
||||
|
||||
```php
|
||||
Field::make('start_date')->after('tomorrow')
|
||||
@@ -39,7 +39,7 @@ Field::make('end_date')->after('start_date')
|
||||
|
||||
### After or equal to (date)
|
||||
|
||||
The field value must be a date after or equal to the given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-after-or-equal)
|
||||
The field value must be a date after or equal to the given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-after-or-equal)
|
||||
|
||||
```php
|
||||
Field::make('start_date')->afterOrEqual('tomorrow')
|
||||
@@ -54,7 +54,7 @@ Field::make('end_date')->afterOrEqual('start_date')
|
||||
|
||||
### Alpha
|
||||
|
||||
The field must be entirely alphabetic characters. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha)
|
||||
The field must be entirely alphabetic characters. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha)
|
||||
|
||||
```php
|
||||
Field::make('name')->alpha()
|
||||
@@ -62,7 +62,7 @@ Field::make('name')->alpha()
|
||||
|
||||
### Alpha Dash
|
||||
|
||||
The field may have alpha-numeric characters, as well as dashes and underscores. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha-dash)
|
||||
The field may have alpha-numeric characters, as well as dashes and underscores. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha-dash)
|
||||
|
||||
```php
|
||||
Field::make('name')->alphaDash()
|
||||
@@ -70,15 +70,23 @@ Field::make('name')->alphaDash()
|
||||
|
||||
### Alpha Numeric
|
||||
|
||||
The field must be entirely alpha-numeric characters. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha-num)
|
||||
The field must be entirely alpha-numeric characters. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha-num)
|
||||
|
||||
```php
|
||||
Field::make('name')->alphaNum()
|
||||
```
|
||||
|
||||
### ASCII
|
||||
|
||||
The field must be entirely 7-bit ASCII characters. [See the Laravel documentation.](https://laravel.com/docs/10.x/validation#rule-ascii)
|
||||
|
||||
```php
|
||||
Field::make('name')->ascii()
|
||||
```
|
||||
|
||||
### Before (date)
|
||||
|
||||
The field value must be a date before a given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-before)
|
||||
The field value must be a date before a given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-before)
|
||||
|
||||
```php
|
||||
Field::make('start_date')->before('first day of next month')
|
||||
@@ -93,7 +101,7 @@ Field::make('end_date')
|
||||
|
||||
### Before or equal to (date)
|
||||
|
||||
The field value must be a date before or equal to the given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-before-or-equal)
|
||||
The field value must be a date before or equal to the given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-before-or-equal)
|
||||
|
||||
```php
|
||||
Field::make('start_date')->beforeOrEqual('end of this month')
|
||||
@@ -108,7 +116,7 @@ Field::make('end_date')
|
||||
|
||||
### Confirmed
|
||||
|
||||
The field must have a matching field of `{field}_confirmation`. [See the Laravel documentation](https://laravel.com/docs/validation#rule-confirmed)
|
||||
The field must have a matching field of `{field}_confirmation`. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-confirmed)
|
||||
|
||||
```php
|
||||
Field::make('password')->confirmed()
|
||||
@@ -117,7 +125,7 @@ Field::make('password_confirmation')
|
||||
|
||||
### Different
|
||||
|
||||
The field value must be different to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-different)
|
||||
The field value must be different to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-different)
|
||||
|
||||
```php
|
||||
Field::make('backup_email')->different('email')
|
||||
@@ -125,7 +133,7 @@ Field::make('backup_email')->different('email')
|
||||
|
||||
### Doesnt Start With
|
||||
|
||||
The field must not start with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-doesnt-start-with)
|
||||
The field must not start with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-doesnt-start-with)
|
||||
|
||||
```php
|
||||
Field::make('name')->doesntStartWith(['admin'])
|
||||
@@ -133,7 +141,7 @@ Field::make('name')->doesntStartWith(['admin'])
|
||||
|
||||
### Doesnt End With
|
||||
|
||||
The field must not end with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-doesnt-end-with)
|
||||
The field must not end with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-doesnt-end-with)
|
||||
|
||||
```php
|
||||
Field::make('name')->doesntEndWith(['admin'])
|
||||
@@ -141,7 +149,7 @@ Field::make('name')->doesntEndWith(['admin'])
|
||||
|
||||
### Ends With
|
||||
|
||||
The field must end with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-ends-with)
|
||||
The field must end with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-ends-with)
|
||||
|
||||
```php
|
||||
Field::make('name')->endsWith(['bot'])
|
||||
@@ -149,7 +157,7 @@ Field::make('name')->endsWith(['bot'])
|
||||
|
||||
### Enum
|
||||
|
||||
The field must contain a valid enum value. [See the Laravel documentation](https://laravel.com/docs/validation#rule-enum)
|
||||
The field must contain a valid enum value. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-enum)
|
||||
|
||||
```php
|
||||
Field::make('status')->enum(MyStatus::class)
|
||||
@@ -157,7 +165,7 @@ Field::make('status')->enum(MyStatus::class)
|
||||
|
||||
### Exists
|
||||
|
||||
The field value must exist in the database. [See the Laravel documentation](https://laravel.com/docs/validation#rule-exists).
|
||||
The field value must exist in the database. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-exists).
|
||||
|
||||
```php
|
||||
Field::make('invitation')->exists()
|
||||
@@ -190,7 +198,7 @@ Field::make('invitation')
|
||||
|
||||
### Filled
|
||||
|
||||
The field must not be empty when it is present. [See the Laravel documentation](https://laravel.com/docs/validation#rule-filled)
|
||||
The field must not be empty when it is present. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-filled)
|
||||
|
||||
```php
|
||||
Field::make('name')->filled()
|
||||
@@ -198,7 +206,7 @@ Field::make('name')->filled()
|
||||
|
||||
### Greater than
|
||||
|
||||
The field value must be greater than another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-gt)
|
||||
The field value must be greater than another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-gt)
|
||||
|
||||
```php
|
||||
Field::make('newNumber')->gt('oldNumber')
|
||||
@@ -206,14 +214,14 @@ Field::make('newNumber')->gt('oldNumber')
|
||||
|
||||
### Greater than or equal to
|
||||
|
||||
The field value must be greater than or equal to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-gte)
|
||||
The field value must be greater than or equal to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-gte)
|
||||
|
||||
```php
|
||||
Field::make('newNumber')->gte('oldNumber')
|
||||
```
|
||||
|
||||
### In
|
||||
The field must be included in the given list of values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-in)
|
||||
The field must be included in the given list of values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-in)
|
||||
|
||||
```php
|
||||
Field::make('status')->in(['pending', 'completed'])
|
||||
@@ -221,7 +229,7 @@ Field::make('status')->in(['pending', 'completed'])
|
||||
|
||||
### Ip Address
|
||||
|
||||
The field must be an IP address. [See the Laravel documentation](https://laravel.com/docs/validation#rule-ip)
|
||||
The field must be an IP address. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-ip)
|
||||
|
||||
```php
|
||||
Field::make('ip_address')->ip()
|
||||
@@ -231,7 +239,7 @@ Field::make('ip_address')->ipv6()
|
||||
|
||||
### JSON
|
||||
|
||||
The field must be a valid JSON string. [See the Laravel documentation](https://laravel.com/docs/validation#rule-json)
|
||||
The field must be a valid JSON string. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-json)
|
||||
|
||||
```php
|
||||
Field::make('ip_address')->json()
|
||||
@@ -239,7 +247,7 @@ Field::make('ip_address')->json()
|
||||
|
||||
### Less than
|
||||
|
||||
The field value must be less than another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-lt)
|
||||
The field value must be less than another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-lt)
|
||||
|
||||
```php
|
||||
Field::make('newNumber')->lt('oldNumber')
|
||||
@@ -247,7 +255,7 @@ Field::make('newNumber')->lt('oldNumber')
|
||||
|
||||
### Less than or equal to
|
||||
|
||||
The field value must be less than or equal to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-lte)
|
||||
The field value must be less than or equal to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-lte)
|
||||
|
||||
```php
|
||||
Field::make('newNumber')->lte('oldNumber')
|
||||
@@ -255,7 +263,7 @@ Field::make('newNumber')->lte('oldNumber')
|
||||
|
||||
### Mac Address
|
||||
|
||||
The field must be a MAC address. [See the Laravel documentation](https://laravel.com/docs/validation#rule-mac)
|
||||
The field must be a MAC address. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-mac)
|
||||
|
||||
```php
|
||||
Field::make('mac_address')->macAddress()
|
||||
@@ -263,7 +271,7 @@ Field::make('mac_address')->macAddress()
|
||||
|
||||
### Multiple Of
|
||||
|
||||
The field must be a multiple of value. [See the Laravel documentation](https://laravel.com/docs/validation#multiple-of)
|
||||
The field must be a multiple of value. [See the Laravel documentation.](https://laravel.com/docs/validation#multiple-of)
|
||||
|
||||
```php
|
||||
Field::make('number')->multipleOf(2)
|
||||
@@ -271,7 +279,7 @@ Field::make('number')->multipleOf(2)
|
||||
|
||||
### Not In
|
||||
|
||||
The field must not be included in the given list of values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-not-in)
|
||||
The field must not be included in the given list of values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-not-in)
|
||||
|
||||
```php
|
||||
Field::make('status')->notIn(['cancelled', 'rejected'])
|
||||
@@ -279,7 +287,7 @@ Field::make('status')->notIn(['cancelled', 'rejected'])
|
||||
|
||||
### Not Regex
|
||||
|
||||
The field must not match the given regular expression. [See the Laravel documentation](https://laravel.com/docs/validation#rule-not-regex)
|
||||
The field must not match the given regular expression. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-not-regex)
|
||||
|
||||
```php
|
||||
Field::make('email')->notRegex('/^.+$/i')
|
||||
@@ -287,7 +295,7 @@ Field::make('email')->notRegex('/^.+$/i')
|
||||
|
||||
### Nullable
|
||||
|
||||
The field value can be empty. This rule is applied by default if the `required` rule is not present. [See the Laravel documentation](https://laravel.com/docs/validation#rule-nullable)
|
||||
The field value can be empty. This rule is applied by default if the `required` rule is not present. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-nullable)
|
||||
|
||||
```php
|
||||
Field::make('name')->nullable()
|
||||
@@ -295,7 +303,7 @@ Field::make('name')->nullable()
|
||||
|
||||
### Prohibited
|
||||
|
||||
The field value must be empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-prohibited)
|
||||
The field value must be empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-prohibited)
|
||||
|
||||
```php
|
||||
Field::make('name')->prohibited()
|
||||
@@ -303,7 +311,7 @@ Field::make('name')->prohibited()
|
||||
|
||||
### Required
|
||||
|
||||
The field value must not be empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required)
|
||||
The field value must not be empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required)
|
||||
|
||||
```php
|
||||
Field::make('name')->required()
|
||||
@@ -311,7 +319,7 @@ Field::make('name')->required()
|
||||
|
||||
### Required With
|
||||
|
||||
The field value must not be empty _only if_ any of the other specified fields are not empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-with)
|
||||
The field value must not be empty _only if_ any of the other specified fields are not empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-with)
|
||||
|
||||
```php
|
||||
Field::make('name')->requiredWith('field,another_field')
|
||||
@@ -319,7 +327,7 @@ Field::make('name')->requiredWith('field,another_field')
|
||||
|
||||
### Required With All
|
||||
|
||||
The field value must not be empty _only if_ all of the other specified fields are not empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-with-all)
|
||||
The field value must not be empty _only if_ all of the other specified fields are not empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-with-all)
|
||||
|
||||
```php
|
||||
Field::make('name')->requiredWithAll('field,another_field')
|
||||
@@ -327,7 +335,7 @@ Field::make('name')->requiredWithAll('field,another_field')
|
||||
|
||||
### Required Without
|
||||
|
||||
The field value must not be empty _only when_ any of the other specified fields are empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-without)
|
||||
The field value must not be empty _only when_ any of the other specified fields are empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-without)
|
||||
|
||||
```php
|
||||
Field::make('name')->requiredWithout('field,another_field')
|
||||
@@ -335,7 +343,7 @@ Field::make('name')->requiredWithout('field,another_field')
|
||||
|
||||
### Required Without All
|
||||
|
||||
The field value must not be empty _only when_ all of the other specified fields are empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-without-all)
|
||||
The field value must not be empty _only when_ all of the other specified fields are empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-without-all)
|
||||
|
||||
```php
|
||||
Field::make('name')->requiredWithoutAll('field,another_field')
|
||||
@@ -343,7 +351,7 @@ Field::make('name')->requiredWithoutAll('field,another_field')
|
||||
|
||||
### Regex
|
||||
|
||||
The field must match the given regular expression. [See the Laravel documentation](https://laravel.com/docs/validation#rule-regex)
|
||||
The field must match the given regular expression. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-regex)
|
||||
|
||||
```php
|
||||
Field::make('email')->regex('/^.+@.+$/i')
|
||||
@@ -351,7 +359,7 @@ Field::make('email')->regex('/^.+@.+$/i')
|
||||
|
||||
### Same
|
||||
|
||||
The field value must be the same as another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-same)
|
||||
The field value must be the same as another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-same)
|
||||
|
||||
```php
|
||||
Field::make('password')->same('passwordConfirmation')
|
||||
@@ -359,7 +367,7 @@ Field::make('password')->same('passwordConfirmation')
|
||||
|
||||
### Starts With
|
||||
|
||||
The field must start with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-starts-with)
|
||||
The field must start with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-starts-with)
|
||||
|
||||
```php
|
||||
Field::make('name')->startsWith(['a'])
|
||||
@@ -367,14 +375,14 @@ Field::make('name')->startsWith(['a'])
|
||||
|
||||
### String
|
||||
|
||||
The field must be a string. [See the Laravel documentation](https://laravel.com/docs/validation#rule-string)
|
||||
The field must be a string. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-string)
|
||||
```php
|
||||
Field::make('name')->string()
|
||||
```
|
||||
|
||||
### Unique
|
||||
|
||||
The field value must not exist in the database. [See the Laravel documentation](https://laravel.com/docs/validation#rule-unique)
|
||||
The field value must not exist in the database. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-unique)
|
||||
|
||||
```php
|
||||
Field::make('email')->unique()
|
||||
@@ -419,7 +427,7 @@ Field::make('email')
|
||||
|
||||
### UUID
|
||||
|
||||
The field must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). [See the Laravel documentation](https://laravel.com/docs/validation#rule-uuid)
|
||||
The field must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). [See the Laravel documentation.](https://laravel.com/docs/validation#rule-uuid)
|
||||
|
||||
```php
|
||||
Field::make('identifer')->uuid()
|
||||
|
||||
@@ -25,7 +25,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::get('posts/create', CreatePost::class);
|
||||
```
|
||||
|
||||
### Adding the form
|
||||
## Adding the form
|
||||
|
||||
There are 5 main tasks when adding a form to a Livewire component class. Each one is essential:
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
</span>
|
||||
@endif
|
||||
|
||||
@if ($prefix)
|
||||
@if (filled($prefix))
|
||||
<span
|
||||
@class([
|
||||
'filament-input-affix-label -me-px',
|
||||
@@ -75,7 +75,7 @@
|
||||
{{ $slot }}
|
||||
</div>
|
||||
|
||||
@if ($suffix)
|
||||
@if (filled($suffix))
|
||||
<span
|
||||
@class([
|
||||
'filament-input-affix-label -ms-px',
|
||||
|
||||
@@ -53,6 +53,13 @@ trait CanBeValidated
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ascii(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->rule('ascii', $condition);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function confirmed(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->rule('confirmed', $condition);
|
||||
|
||||
@@ -162,11 +162,6 @@ trait HasAffixes
|
||||
return $this->evaluate($this->prefixLabel);
|
||||
}
|
||||
|
||||
public function getPostfixLabel(): ?string
|
||||
{
|
||||
return $this->getSuffixLabel();
|
||||
}
|
||||
|
||||
public function getSuffixLabel(): ?string
|
||||
{
|
||||
return $this->evaluate($this->suffixLabel);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: Adding an infolist to a Livewire component
|
||||
---
|
||||
|
||||
## Setting up the Livewire component
|
||||
|
||||
First, generate a new Livewire component:
|
||||
|
||||
```bash
|
||||
php artisan make:livewire ViewProduct
|
||||
```
|
||||
|
||||
Then, render your Livewire component on the page:
|
||||
|
||||
```blade
|
||||
@livewire('view-product')
|
||||
```
|
||||
|
||||
Alternatively, you can use a full-page Livewire component:
|
||||
|
||||
```php
|
||||
use App\Http\Livewire\ViewProduct;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('products/{product}', ViewProduct::class);
|
||||
```
|
||||
|
||||
## Adding the infolist
|
||||
|
||||
Next, add a method to the Livewire component which accepts an `$infolist` object, modifies it, and returns it:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Infolist;
|
||||
|
||||
public function productInfolist(Infolist $infolist): Infolist
|
||||
{
|
||||
return $infolist
|
||||
->record($this->product)
|
||||
->schema([
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
Finally, render the infolist in the Livewire component's view:
|
||||
|
||||
```blade
|
||||
{{ $this->productInfolist }}
|
||||
```
|
||||
|
||||
## Passing data to the infolist
|
||||
|
||||
You can pass data to the infolist in two ways:
|
||||
|
||||
Either pass an Eloquent model instance to the `record()` method of the infolist, to automatically map all the model attributes and relationships to the entries in the infolist's schema:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Infolist;
|
||||
|
||||
public function productInfolist(Infolist $infolist): Infolist
|
||||
{
|
||||
return $infolist
|
||||
->record($this->product)
|
||||
->schema([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('category.name'),
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, you can pass an array of data to the `state()` method of the infolist, to manually map the data to the entries in the infolist's schema:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Infolist;
|
||||
|
||||
public function productInfolist(Infolist $infolist): Infolist
|
||||
{
|
||||
return $infolist
|
||||
->state([
|
||||
'name' => 'MacBook Pro',
|
||||
'category' => [
|
||||
'name' => 'Laptops',
|
||||
],
|
||||
// ...
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('category.name'),
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
```
|
||||
@@ -13,7 +13,7 @@
|
||||
"illuminate/console": "^9.0|^10.0",
|
||||
"illuminate/filesystem": "^9.0|^10.0",
|
||||
"illuminate/support": "^9.0|^10.0",
|
||||
"spatie/laravel-settings": "^2.2"
|
||||
"spatie/laravel-settings": "^2.2|^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
||||
import AlpineFloatingUI from '@awcodes/alpine-floating-ui'
|
||||
import AlpineLazyLoadAssets from 'alpine-lazy-load-assets'
|
||||
import Focus from '@alpinejs/focus'
|
||||
import Sortable from './sortable'
|
||||
|
||||
@@ -6,6 +7,7 @@ document.addEventListener('alpine:init', () => {
|
||||
window.Alpine.plugin(Focus)
|
||||
window.Alpine.plugin(Sortable)
|
||||
window.Alpine.plugin(AlpineFloatingUI)
|
||||
window.Alpine.plugin(AlpineLazyLoadAssets)
|
||||
})
|
||||
|
||||
// https://github.com/laravel/framework/blob/5299c22321c0f1ea8ff770b84a6c6469c4d6edec/src/Illuminate/Translation/MessageSelector.php#L15
|
||||
|
||||
@@ -164,6 +164,9 @@
|
||||
|
||||
@if ($tag === 'button')
|
||||
<button
|
||||
@if (($keyBindings || $tooltip) && (! $hasFileUploadLoadingIndicator))
|
||||
x-data="{}"
|
||||
@endif
|
||||
@if ($keyBindings)
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
|
||||
@@ -49,15 +49,21 @@
|
||||
@endphp
|
||||
|
||||
@if ($tag === 'button')
|
||||
<button {{ $attributes
|
||||
->merge([
|
||||
'disabled' => $disabled,
|
||||
'type' => 'button',
|
||||
'wire:loading.attr' => 'disabled',
|
||||
'wire:target' => ($hasLoadingIndicator && $loadingIndicatorTarget) ? $loadingIndicatorTarget : null,
|
||||
], escape: false)
|
||||
->class([$buttonClasses])
|
||||
}}>
|
||||
<button
|
||||
@if ($keyBindings)
|
||||
x-data="{}"
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
{{ $attributes
|
||||
->merge([
|
||||
'disabled' => $disabled,
|
||||
'type' => 'button',
|
||||
'wire:loading.attr' => 'disabled',
|
||||
'wire:target' => ($hasLoadingIndicator && $loadingIndicatorTarget) ? $loadingIndicatorTarget : null,
|
||||
], escape: false)
|
||||
->class([$buttonClasses])
|
||||
}}
|
||||
>
|
||||
@if ($icon)
|
||||
<x-filament::icon
|
||||
:name="$icon"
|
||||
@@ -95,7 +101,13 @@
|
||||
@endif
|
||||
</button>
|
||||
@elseif ($tag === 'a')
|
||||
<a {{ $attributes->class([$buttonClasses]) }}>
|
||||
<a
|
||||
@if ($keyBindings)
|
||||
x-data="{}"
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
{{ $attributes->class([$buttonClasses]) }}
|
||||
>
|
||||
@if ($icon)
|
||||
<x-filament::icon
|
||||
:name="$icon"
|
||||
@@ -127,6 +139,10 @@
|
||||
@csrf
|
||||
|
||||
<button
|
||||
@if ($keyBindings)
|
||||
x-data="{}"
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
type="submit"
|
||||
{{
|
||||
$attributes
|
||||
|
||||
@@ -86,15 +86,15 @@
|
||||
|
||||
@if ($tag === 'button')
|
||||
<button
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
@if ($keyBindings)
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
@if ($tooltip)
|
||||
x-tooltip.raw="{{ $tooltip }}"
|
||||
@endif
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
{{
|
||||
$attributes
|
||||
->merge([
|
||||
@@ -137,15 +137,15 @@
|
||||
</button>
|
||||
@elseif ($tag === 'a')
|
||||
<a
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
@if ($keyBindings)
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
@if ($tooltip)
|
||||
x-tooltip.raw="{{ $tooltip }}"
|
||||
@endif
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
{{
|
||||
$attributes
|
||||
->merge([
|
||||
|
||||
@@ -115,15 +115,15 @@
|
||||
</a>
|
||||
@elseif ($tag === 'button')
|
||||
<button
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
@if ($keyBindings)
|
||||
x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}
|
||||
@endif
|
||||
@if ($tooltip)
|
||||
x-tooltip.raw="{{ $tooltip }}"
|
||||
@endif
|
||||
@if ($keyBindings || $tooltip)
|
||||
x-data="{}"
|
||||
@endif
|
||||
{{
|
||||
$attributes
|
||||
->merge([
|
||||
|
||||
@@ -358,9 +358,9 @@ public function table(Table $table): Table
|
||||
}
|
||||
```
|
||||
|
||||
## Controlling the max height of the filters dropdown
|
||||
## Controlling the maximum height of the filters dropdown
|
||||
|
||||
To add a max height to the filters dropdown content, so that they scroll, you may use the `filtersFormMaxHeight()` method, passing a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length):
|
||||
To add a maximum height to the filters dropdown content, so that they scroll, you may use the `filtersFormMaxHeight()` method, passing a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length):
|
||||
|
||||
```php
|
||||
use Filament\Tables\Table;
|
||||
@@ -479,4 +479,4 @@ public function table(Table $table): Table
|
||||
->label('Filter'),
|
||||
);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
@@ -106,6 +106,53 @@ BulkAction::make('delete')
|
||||
|
||||
The function allows you to access the current table `$records` that are selected. It is an Eloquent collection of models.
|
||||
|
||||
### Grouping bulk actions
|
||||
|
||||
You may use a `BulkActionGroup` object to [group multiple bulk actions together](../actions/grouping-actions) in a dropdown. Any bulk actions that remain outside of the `BulkActionGroup` will be rendered next to the dropdown's trigger button:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('delete')
|
||||
->requiresConfirmation()
|
||||
->action(fn (Collection $records) => $records->each->delete()),
|
||||
BulkAction::make('forceDelete')
|
||||
->requiresConfirmation()
|
||||
->action(fn (Collection $records) => $records->each->forceDelete()),
|
||||
]),
|
||||
BulkAction::make('export')->action(fn (Collection $records) => ...),
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, if all of your bulk actions are grouped, you can use the shorthand `groupedBulkActions()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->groupedBulkActions([
|
||||
BulkAction::make('delete')
|
||||
->requiresConfirmation()
|
||||
->action(fn (Collection $records) => $records->each->delete()),
|
||||
BulkAction::make('forceDelete')
|
||||
->requiresConfirmation()
|
||||
->action(fn (Collection $records) => $records->each->forceDelete()),
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
### Deselecting records once a bulk action has finished
|
||||
|
||||
You may deselect the records after a bulk action has been executed using the `deselectRecordsAfterCompletion()` method:
|
||||
@@ -281,4 +328,4 @@ use Filament\Tables\Actions\ActionGroup;
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
])->tooltip('More actions');
|
||||
```
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::get('products', ListProducts::class);
|
||||
```
|
||||
|
||||
### Adding the table
|
||||
## Adding the table
|
||||
|
||||
There are 3 tasks when adding a table to a Livewire component class:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user