mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-30 23:04:45 +02:00
34 lines
656 B
PHP
34 lines
656 B
PHP
<?php
|
|
|
|
namespace App\Traits\Filament;
|
|
|
|
use Closure;
|
|
use Filament\Forms\Form;
|
|
|
|
trait CanModifyForm
|
|
{
|
|
/** @var array<Closure> */
|
|
protected static array $customFormModifications = [];
|
|
|
|
public static function modifyForm(Closure $closure): void
|
|
{
|
|
static::$customFormModifications[] = $closure;
|
|
}
|
|
|
|
public static function defaultForm(Form $form): Form
|
|
{
|
|
return $form;
|
|
}
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
$form = static::defaultForm($form);
|
|
|
|
foreach (static::$customFormModifications as $closure) {
|
|
$form = $closure($form);
|
|
}
|
|
|
|
return $form;
|
|
}
|
|
}
|