What is the best way to separate the create form and the edit form in a resource

public static function form(Form $form): Form
{
return $form
->schema([
Section::make()
->visible(fn (Page $livewire) => $livewire instanceof CreateModel)
->schema([
// ...
]),
Section::make()
->visible(fn (Page $livewire) => $livewire instanceof EditModel)
->schema([
// ...
])
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Section::make()
->visible(fn (Page $livewire) => $livewire instanceof CreateModel)
->schema([
// ...
]),
Section::make()
->visible(fn (Page $livewire) => $livewire instanceof EditModel)
->schema([
// ...
])
]);
}
Is this a good solution ?
2 Replies
DrByte
DrByte14mo ago
In what ways do you want them to be different? Would it make sense to use one form but simply hide certain elements using ->visibleOn('create') (or 'edit') or ->hiddenOn('create')/'edit'. ... or use ->visible(closure)/->hidden(closure) ?
developer
developer9mo ago
this is an old question but here is the solution: move the form from the resource to its corresponding create or edit page, super easy
Want results from more Discord servers?
Add your server