Custom field with api call

I need to build a custom field to make an api call if i understand well, the api call is made with an action (and i will go into this later) my problam now is: i have generated the form field with make:form-field with my two files: resources/views/forms/components/myfield.blade.php and app/forms/components/myfield.php in my itemResouece.php where i have the other form fields, i simply add Forms\Components\Myfield::make('name') but i get this error Class "Forms\Components\Opendata" not found
4 Replies
Tieme
Tieme13mo ago
Can you please read the https://discord.com/channels/883083792112300104/1167015843020943390 So please add some code examples of the files that where created.
Soundmit
SoundmitOP13mo ago
yes, sorry What I am trying to do: I want to make a custom text field that send the text to an external API and get back some data at the moment i'm interested in creating the custom field What I did: following the proposed tutorial (Build a Custom Form Field on laracast) i've made
php artisan make:form-field
php artisan make:form-field
2 files are created - resources/views/forms/components/myfield.blade.php and app/forms/components/opendata - app/forms/components/opendata.php Now, in my Filament/Resources/CompanyResource.php
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Opendata::make('opendata'),
...
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Opendata::make('opendata'),
...
My issue/the error: then when i try to show the form i get this error Class "Forms\Components\Opendata" not found
Tieme
Tieme13mo ago
Thanks for the code. The problem is that the namespace Forms\Components\ is wrong. It needs to be App\Forms\Components\
public static function form(Form $form): Form
{
return $form
->schema([
\App\Forms\Components\Opendata::make('opendata'),
public static function form(Form $form): Form
{
return $form
->schema([
\App\Forms\Components\Opendata::make('opendata'),
The place where the Opendata field is and not the Filament forms components.
Soundmit
SoundmitOP13mo ago
thanks
Want results from more Discord servers?
Add your server