mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
wip
This commit is contained in:
@@ -6,6 +6,7 @@ use Filament\Forms\Components\Concerns\CanConcealFields;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -16,6 +17,8 @@ trait HasForm
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
protected $form;
|
||||
|
||||
public $temporaryUploadedFiles = [];
|
||||
|
||||
public function clearTemporaryUploadedFile($name)
|
||||
@@ -55,9 +58,20 @@ trait HasForm
|
||||
}
|
||||
}
|
||||
|
||||
protected function form()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this);
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
{
|
||||
if ($this->form !== null) {
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
return $this->form = $this->form(
|
||||
Form::for($this),
|
||||
);
|
||||
}
|
||||
|
||||
public function getPropertyDefaults()
|
||||
|
||||
@@ -21,9 +21,9 @@ class Login extends Component
|
||||
|
||||
public $remember = false;
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this)
|
||||
return $form
|
||||
->schema([
|
||||
Components\TextInput::make('email')
|
||||
->label('filament::auth/login.form.email.label')
|
||||
|
||||
@@ -17,9 +17,9 @@ class RequestPassword extends Component
|
||||
|
||||
public $email;
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this)
|
||||
return $form
|
||||
->schema([
|
||||
Components\TextInput::make('email')
|
||||
->label('filament::auth/request-password.form.email.label')
|
||||
|
||||
@@ -25,9 +25,9 @@ class ResetPassword extends Component
|
||||
|
||||
public $user;
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this)
|
||||
return $form
|
||||
->schema([
|
||||
Components\TextInput::make('email')
|
||||
->label('filament::auth/reset-password.form.email.label')
|
||||
|
||||
@@ -18,10 +18,10 @@ class EditAccount extends Page
|
||||
|
||||
public static $view = 'filament::edit-account';
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return static::getResource()::form(
|
||||
Form::for($this)->model(static::getModel()),
|
||||
$form->model(static::getModel()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,25 @@
|
||||
|
||||
namespace Filament\Resources\Forms;
|
||||
|
||||
use Filament\Resources\Forms\Form;
|
||||
|
||||
trait HasForm
|
||||
{
|
||||
use \Filament\Forms\HasForm;
|
||||
|
||||
protected function form()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this);
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
{
|
||||
if ($this->form !== null) {
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
return $this->form = $this->form(
|
||||
Form::for($this),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Resources\Pages;
|
||||
|
||||
use Filament\Filament;
|
||||
use Filament\Resources\Forms\Form;
|
||||
use Filament\Resources\Forms\HasForm;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -48,10 +49,10 @@ class CreateRecord extends Page
|
||||
];
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return static::getResource()::form(
|
||||
$this->form()->model(static::getModel()),
|
||||
$form->model(static::getModel()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Resources\Pages;
|
||||
|
||||
use Filament\Filament;
|
||||
use Filament\Resources\Forms\Form;
|
||||
use Filament\Resources\Forms\HasForm;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -56,10 +57,10 @@ class EditRecord extends Page
|
||||
];
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return static::getResource()::form(
|
||||
$this->form()->model(static::getModel()),
|
||||
$form->model(static::getModel()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ class AttachRecord extends Component
|
||||
$this->related = null;
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return Form::for($this)
|
||||
return $form
|
||||
->schema([
|
||||
Select::make('related')
|
||||
->label((string) Str::of($this->getRelationship())->singular()->ucfirst())
|
||||
|
||||
@@ -46,10 +46,10 @@ class CreateRecord extends Component
|
||||
$this->fillWithFormDefaults();
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
return $this->manager::form(
|
||||
Form::for($this)->model(get_class($this->owner->{$this->getRelationship()}()->getModel())),
|
||||
$form->model(get_class($this->owner->{$this->getRelationship()}()->getModel())),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,9 @@ class EditRecord extends Component
|
||||
'switchRelationManagerEditRecord' => 'switchRecord',
|
||||
];
|
||||
|
||||
public function getForm()
|
||||
public function form(Form $form)
|
||||
{
|
||||
$form = Form::for($this)->model(get_class($this->owner->{$this->getRelationship()}()->getModel()));
|
||||
|
||||
return $this->manager::form($form);
|
||||
return $this->manager::form($form->model(get_class($this->owner->{$this->getRelationship()}()->getModel())));
|
||||
}
|
||||
|
||||
public function getQuery()
|
||||
|
||||
Reference in New Issue
Block a user