mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge branch '3.x' into 4.x
This commit is contained in:
@@ -508,6 +508,20 @@ Repeater::make('members')
|
||||
|
||||
<AutoScreenshot name="forms/fields/repeater/labelled" alt="Repeater with item labels" version="4.x" />
|
||||
|
||||
## Numbering repeater items
|
||||
|
||||
You can add the repeater item's number next to its label using the `itemNumbers()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Repeater;
|
||||
|
||||
Repeater::make('members')
|
||||
->schema([
|
||||
// ...
|
||||
])
|
||||
->itemNumbers()
|
||||
```
|
||||
|
||||
## Simple repeaters with one field
|
||||
|
||||
You can use the `simple()` method to create a repeater with a single field, using a minimal design
|
||||
|
||||
@@ -61,6 +61,8 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
protected string | Closure | null $itemLabel = null;
|
||||
|
||||
protected bool | Closure $hasItemNumbers = false;
|
||||
|
||||
protected Field | Closure | null $simpleField = null;
|
||||
|
||||
protected Alignment | string | Closure | null $addActionAlignment = null;
|
||||
@@ -1036,6 +1038,13 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function itemNumbers(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->hasItemNumbers = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fillFromRelationship(): void
|
||||
{
|
||||
$this->state(
|
||||
@@ -1173,6 +1182,11 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
return $this->itemLabel !== null;
|
||||
}
|
||||
|
||||
public function hasItemNumbers(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->hasItemNumbers);
|
||||
}
|
||||
|
||||
public function simple(Field | Closure | null $field): static
|
||||
{
|
||||
$this->simpleField = $field;
|
||||
|
||||
Reference in New Issue
Block a user