how you render button without click it
public function getActions(): array
{
$formFilled = $this->isFormFilled();
return [
Actions\CreateAction::make()
->label('Generate from ChatGPT')
->action(fn () => $this->fillFormFields1())
->disabled($formFilled)
->color($formFilled ? 'success' : 'secondary')
// ->color('success')
->outlined()
];
}
protected function isFormFilled(): bool
{
$requiredFields = ['type', 'difficulty_level'];
foreach ($requiredFields as $field) {
if (empty($this->data[$field])) {
return false;
}
}
// $again=$this->make();
return true;
}
This is my code write in filament/resources/materialresources/page/creatematerial.php file
i want when two fill are fillup then the button color will change so i write this logic but when i fill the field then color was not change but after fill the field when i click on button then only the color was change.
so i try to fix it can you help me in it
3 Replies
Maybe you could try to add this: part a mount() function instead of the getActions()
Solution
their is a reactive() function in filament
i use that in materialreources .php file now it work