createOptionForm - how to import form schema, is it possible?
I'm using a separate form schema to try and cut down on repetition and mistakes, and so far so good it imports and seems to work:
As part of that schema I want there to be a createOptionForm on one of the drop down selects that imports the schema from yet another file ():
But I'm not sure what I can pass to createOptionForm to make it work, I've tried a bunch of stuff like throwing darts at a board and got nowhere.
I've tried:
Which doesn't throw an error like other options, but when clicking the button nothing happens... is it not possible to nest these imports?
9 Replies
Create a public function in your resource then call it with ->createOptionForm(PrimaryResource::getFormGlobalSchema()) for example
I'm not using the admin portion of the package, but the form builder on its own.
But I created a public function on the model itself that will suffice I assume? Which I've done but it's still not doing anything when I click the button.
if I ddump:
->createOptionForm(dd(Category::getFormGlobalSchema())),
the screenshot is what I get, so it is passing an array with the filament card and two textinputs.
So actually I think the problem is nothing to do with this.
...and yeah I've just tried it without any importing and it doesn't work for me. It's not opening the modal for some reason. Hmm. At least I know it's nothing to do with the importing.the problem is that filament doesnt know how to actually create the record
so it doesn’t want to waste energy on opening the modal to do nothing
you either need to define relationship() or createOptionUsing()
I'm being gaslighted day to day by AI chat bots and now FIlament!? When will it end.
I guess I was so preoccupied with getting the modal to appear I didn't even think that far ahead as to what it was actually going to create. My bad guys, sorry, thanks for the help.
Sorry @Dan Harrin , can you advise please. I'm sure I'm doing something super obviously wrong but I'm tearing my hair out (and don't have much left to begin with). I've created a brand new project, installed Jetstream, Filament Admin, Filament Forms, followed the instructions for both, and just for testing purposes created an additional model called Department with a single name field, and linked it to the user model with a BelongsTo:
User model:
Create.php:
That should work shouldn't it? But when I click the button to bring up the modal, a network request is sent to fetch the modal, but nothing else happens and nothing shows.
Am I missing something here? Again I don't want to be that guy, so I am sorry.
are you missing
{{ $this->modal }}
in the view, outside of the <form>
?Oh man, I did not, no. I'm shifting uncomfortably in my seat now. Is that documented yet?
Either way that gets me to a point where the modal now looks like it's loading the overlay but no form is showing. But I'll take it, that's progress!
yes its in the createOptionForm() section
any console errors?
also, does your Livewire component have just 1 root html element?
Yeah all fixed - right on both counts. Sorry again Dan, you're a lifesaver.