phplaravellaravel-filament

Adding TextInput only during create, not update using Filament


I try to build a user form in Filament, which will have password field only in create action, not update.

So I try to limit this way:

use Filament\Pages\Page;
...

TextInput::make("password")
    ->required(fn (Page $limewire): bool => $limewire instanceof CreateRecord),

The error I get is:

Target [Filament\Pages\Page] is not instantiable.

How can I get over this problem?


Solution

  • I found a much easier solution:

    public static function form(Form $form): Form
    {
        $isCreate = $form->getOperation() === "create";
    

    and than:

    TextInput::make("password")
        ->visible($isCreate),