filament-api icon indicating copy to clipboard operation
filament-api copied to clipboard

Call to undefined method getValidationRules() in FilamentAPIServices.php

Open rostlerkk opened this issue 1 year ago • 1 comments

Hi,

I encountered an issue with your package tomatophp/filament-api while using it in my Filament 3 project.

Problem: The following error occurs when trying to process validation rules: Call to undefined method Filament\Forms\Components\Grid::getValidationRules()

Cause: In the file: vendor/tomatophp/filament-api/src/Services/FilamentAPIServices.php

The line: $rules[$component->getId()] = array_values($component->getValidationRules());

assumes that all components have a getValidationRules() method. However, this is not true for components like Grid, which results in the error.

Suggested Fix: Replace the line mentioned above with this:

if (method_exists($component, 'getValidationRules')) { $rules[$component->getId()] = array_values($component->getValidationRules()); }

Environment Details: • Laravel Version: 11.x • Filament Version: 3.x • PHP Version: 8.x

Could you please address this issue in the next release?

Thank you for your work on this package!

Best regards,

Steve

rostlerkk avatar Jan 08 '25 14:01 rostlerkk