My Resorce has Form I want to call it or inheritance this form in another palce

My Resorce has Form I want to call it or inheritance this form in another palce How do it $formSchema = TaskResource::form(); > dd( $formSchema);
5 Replies
Alnuaimi
Alnuaimi2mo ago
I want to call form in another Resorsce
LeandroFerreira
LeandroFerreira2mo ago
public static function form(Form $form): Form
{
return AnotherResource::form($form);
}
public static function form(Form $form): Form
{
return AnotherResource::form($form);
}
Alnuaimi
Alnuaimi2mo ago
Thanks ,but alsoe I want use it in Widgets like getFormSchema
Desmond Njuguna
Desmond Njuguna2mo ago
you can define a getForm static method in the corresponding model then call the form in any resource you want Eg if you have a tag model and the resources, in the Tag model define a new methid like so public static function getForm(): array { return [ TextInput::make('name') ->required() ->maxLength(255), ColorPicker::make('color') ->required(), ]; } Then in the tagresource form method do this public static function form(Form $form): Form { return $form ->schema(Task::getForm()); } I suppose you have a userresource and you might want to create a new tag without necessarily goung back to the tag resource, so in the tag form component of the userresource form method you can chain the method createOptionForm(App\Models\Tag::getForm()) and have it complete as so Select::make('tags') ->relationship('tags', 'name',) ->multiple() ->searchable() ->preload() ->createOptionForm(Tag::getForm()) Hope this is what youre looking for
Want results from more Discord servers?
Add your server
More Posts
Building Custom Field That Requires 2 Model AttributesHi guys! I'm building a custom field, and the custom fields needs to save to two columns in a model.Repeater actions orderIs it possible to set the order of repeater actions (edit, delete, reorder)? I'm using https://filamCustomize VerifyEmail template and other login related emailsOverriding `sendEmailVerificationNotification()` in User model doesnt work as filament creates the nPass Data From Filament TextInput to Livewire ComponentI have added a livewire component on the create page of resource and wanted to pass a TextInput::makModify Export Action download URL linkMy app is deployed in a sub-folder https://example.com/my-app. How can i modify the download .csv orI try to seed using has function for relationship but does not create child record.I can propertyServices separately, it works. I wonder what I made wrong on using has in PropertySeedmultiple panels on single dashboard as tabs?Wondering how/if we can have multiple panels visible on a common dashboard for easy navigation! InForm does not revalidate after change valueI have set unique(ignoreRecord:true), when it to validate with red message the submit button is alsogetPageTableQuery() function on Simple Resource.Hi all, i have a question . currrently im using simple resource in my project. i wanted to use getPaHow modify rule for unique() when it must be unique if another field eg group are the same?I have a house that belongs to a villege. In the same villege house_no must be unique but in differe