F
Filamentβ€’3mo ago
sohail

How to change wizard submit action text on On the same form for update and create (V4)

Hi i have a same wizard form in both create and update livewire component like so Create Component
public function form(Schema $schema): Schema
{
return ProductForm::configure($schema)
->statePath('data')
->model(Product::class);
}
public function form(Schema $schema): Schema
{
return ProductForm::configure($schema)
->statePath('data')
->model(Product::class);
}
Update Component
public function form(Schema $schema): Schema
{
return ProductForm::configure($schema)
->statePath('data')
->model($this->product);
}
public function form(Schema $schema): Schema
{
return ProductForm::configure($schema)
->statePath('data')
->model($this->product);
}
Product Form
public static function configure(Schema $schema): Schema
{
return $schema->components([
Wizard::make([...steps here])
->submitAction(new HtmlString(Blade::render(<<<'blade'
<flux:button @click="type='submit' variant="primary">Create</flux:button> // how can i have Create text for Create form and Update Text for update form
blade,
)))
}
public static function configure(Schema $schema): Schema
{
return $schema->components([
Wizard::make([...steps here])
->submitAction(new HtmlString(Blade::render(<<<'blade'
<flux:button @click="type='submit' variant="primary">Create</flux:button> // how can i have Create text for Create form and Update Text for update form
blade,
)))
}
2 Replies
Will Aguilar
Will Aguilarβ€’3mo ago
This should work πŸ™‚
->submitAction(new HtmlString(Blade::render(<<<'blade'
<x-filament::button
type="submit"
size="sm"
>
{{ $operation }}
</x-filament::button>
blade, [
'operation' => $schema->getOperation() === 'create' ? 'Create' : 'Update',
])))
->submitAction(new HtmlString(Blade::render(<<<'blade'
<x-filament::button
type="submit"
size="sm"
>
{{ $operation }}
</x-filament::button>
blade, [
'operation' => $schema->getOperation() === 'create' ? 'Create' : 'Update',
])))
$schema->getOperation() will get you the current operation from $schema Blade:render second parameter is the data you want to pass into the view. You can pass your array in that second parameter
LeandroFerreira
LeandroFerreiraβ€’3mo ago
if you are using a wizard in the Resource, you should use this trait: CreatePage in EditPage you can use EditRecord\Concerns\HasWizard Then, you can customize the button:
protected function getSubmitFormAction(): Action
{
return parent::getSubmitFormAction()
->label('Create..');
}
protected function getSubmitFormAction(): Action
{
return parent::getSubmitFormAction()
->label('Create..');
}

Did you find this page helpful?