F
Filament9mo ago
Itachi

Why in v3 action method donot call another function

Actions\CreateAction::make()
->label('Generate')
->action(fn () => $this->fillFormFields1())
Actions\CreateAction::make()
->label('Generate')
->action(fn () => $this->fillFormFields1())
this is my code i am trying to call "fillFormFields() " function when i click on generate button thenn it donot call fillformfield function, it works in v2 but now it doesnot work on v3 any one can help
8 Replies
Malcolm Turntbull
The method you're calling is "fillFormFields1", not "fillFormFields" - there's a "1" at the end.
Itachi
Itachi9mo ago
now? please any one tell me in between action how call another function
Itachi
Itachi9mo ago
nosir it is not a modal
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()
->label('Generate')
->action(fn () => $this->fillFormFields()),


];
}
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()
->label('Generate')
->action(fn () => $this->fillFormFields()),


];
}
LeandroFerreira
LeandroFerreira9mo ago
so this is a redirect to the create page. If you want to call a function, you should use the mount method
public function mount(): void
{
parent::mount();

//your code here..
}
public function mount(): void
{
parent::mount();

//your code here..
}
Itachi
Itachi9mo ago
sir i try to call fillformfields function when i click on generate function
public function getActions(): array
{
$formFilled = empty($this->data['lesson_id']) || empty($this->data['difficulty_level']);
return [
Actions\CreateAction::make()
->label('Generate from ChatGPT')
->action(fn () => $this->fillFormFields())
->disabled($formFilled)
->color($formFilled ? 'secondary' : 'success')
->outlined()
->extraAttributes(['class' => 'abc', 'style' => 'float:right']),
];
}
public function getActions(): array
{
$formFilled = empty($this->data['lesson_id']) || empty($this->data['difficulty_level']);
return [
Actions\CreateAction::make()
->label('Generate from ChatGPT')
->action(fn () => $this->fillFormFields())
->disabled($formFilled)
->color($formFilled ? 'secondary' : 'success')
->outlined()
->extraAttributes(['class' => 'abc', 'style' => 'float:right']),
];
}
this function is already work on v2 but not work in v3 so tell me what modify i do
LeandroFerreira
LeandroFerreira9mo ago
I don't know why, but if you have a CreatePage this action should redirect to the create page..
Itachi
Itachi8mo ago
i write this in create page i have created their a button when i click on that button it should call fillFormFields() function ,for this functionlity i write this code
->action(fn () => $this->fillFormFields())
->action(fn () => $this->fillFormFields())
but it donot call fillFormFields() function you have any other way