Pass parameter from RelationManager createAction to form
Hi,
I'm trying to have a custom create button in my RelationManager in order to create a new record with parameter(s).
I've searched and tried several things but still struggle on this.
My first idea was to populate an hidden field and use its value in order to perform some custom things, so I tried and used
beforeFormFilled()
but am unable to populate/retrieve the value.
I don't know if I can use an url then access the request().
Can someone help me and point me to the right direction?Solution:Jump to solution
Ok, I managed to do it:
```php
->beforeFormFilled(
function ($livewire) {
$livewire->mountedTableActionsData[0]['action_type'] = 'test';...
13 Replies
Same here.
Try this if it helps
Or this
It would help if you shared your current code and what exactly you want to do so we understand better.
My first idea was to populate an hidden fieldDid you use a
Hidden::make()
field or a field that's hidden TextInput::make()->hidden()
? Last one won't be included in the request.Great tip, I didn't know that difference between Hidden::make and Texinput::make()->hidden(), usefull!
One is a
type="hidden"
and the other one is a field that's hidden/removed from DOM and therefore it's not sentHello @Dennis Koch and @PabloZagni ,
Thanks for helping, very much appreciated!
What I am trying to achieve is, from a createAction on a RelationManager, passing a parameter to the resource form so that I can customize the resource form.
My idea was to hide the action_type field because I don't need to save it in the DB.
Here is an example of my code: first, I am trying to just see the value "test" in the Action Type field, then I would hide it.
I don't know if it is the best way to do it.
`
My idea was to hide the action_type field because I don't need to save it in the DB.Yeah, but that also means it's not included in the result. You can try accessing it directly via
$livewire->data
or removing it before save.I get this message: Property [$data] not found on component: [app.filament.application.resources.client-resource.relation-managers.orders-relation-manager]
😦
I think it's
$formData
for RMs
Setting the default to the actual value doesn't really make sense though.
$formData
doesn't work either...
Setting the default to the actual value doesn't really make sense though.Yes, but how can I check if the field is populated during development? @PabloZagni : can you tell me how you can check the value of your
$data['type’]
(in your second screenshot) in your form?Solution
Ok, I managed to do it:
I don't know if it is the best/simplest way to do it, but that works!
Thanks again, guys! 👍