mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 06:36:51 +01:00 
			
		
		
		
	Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			34 lines
		
	
	
		
			684 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			684 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Traits\Filament;
 | 
						|
 | 
						|
use Closure;
 | 
						|
use Filament\Schemas\Schema;
 | 
						|
 | 
						|
trait CanModifyForm
 | 
						|
{
 | 
						|
    /** @var array<Closure> */
 | 
						|
    protected static array $customFormModifications = [];
 | 
						|
 | 
						|
    public static function modifyForm(Closure $closure): void
 | 
						|
    {
 | 
						|
        static::$customFormModifications[] = $closure;
 | 
						|
    }
 | 
						|
 | 
						|
    public static function defaultForm(Schema $schema): Schema
 | 
						|
    {
 | 
						|
        return $schema;
 | 
						|
    }
 | 
						|
 | 
						|
    public static function form(Schema $schema): Schema
 | 
						|
    {
 | 
						|
        $schema = static::defaultForm($schema);
 | 
						|
 | 
						|
        foreach (static::$customFormModifications as $closure) {
 | 
						|
            $schema = $closure($schema);
 | 
						|
        }
 | 
						|
 | 
						|
        return $schema;
 | 
						|
    }
 | 
						|
}
 |