bahamagician
bahamagician
FFilament
Created by bahamagician on 4/18/2024 in #❓┊help
Set State of Select Field After Dynamically Populating Via Dependent Field
This did it, thanks! Is it okay to leave the random function in there for the wire:key? Is that going to cause any interference with other components?
20 replies
FFilament
Created by bahamagician on 4/18/2024 in #❓┊help
Set State of Select Field After Dynamically Populating Via Dependent Field
So it seems that if I do the following, the service_call_id state gets updated but the select field doesn't reflect the state change on the front end. It still says "Select an option". Is there a way to trigger the form field to update to reflect the state of that field?
Forms\Components\Select::make('customer_id')
->relationship('customer', 'email')
->live(onBlur: true)
->afterStateUpdated(function (Get $get, Set $set, Select $component) {
$options = $component->getContainer()->getComponent('service_call_select')->getOptions();
$set('service_call_id', array_key_first($options));
})
->searchable()
->required(),
Forms\Components\Select::make('service_call_id')
->options(fn (Get $get): Collection => ServiceCall::query()
->whereRelation('workOrder.customer', 'id', $get('customer_id'))
->orderBy('id', 'desc')
->pluck('id', 'id'))
->live()
->key('service_call_select')
->required(),
Forms\Components\Select::make('customer_id')
->relationship('customer', 'email')
->live(onBlur: true)
->afterStateUpdated(function (Get $get, Set $set, Select $component) {
$options = $component->getContainer()->getComponent('service_call_select')->getOptions();
$set('service_call_id', array_key_first($options));
})
->searchable()
->required(),
Forms\Components\Select::make('service_call_id')
->options(fn (Get $get): Collection => ServiceCall::query()
->whereRelation('workOrder.customer', 'id', $get('customer_id'))
->orderBy('id', 'desc')
->pluck('id', 'id'))
->live()
->key('service_call_select')
->required(),
20 replies
FFilament
Created by bahamagician on 4/18/2024 in #❓┊help
Set State of Select Field After Dynamically Populating Via Dependent Field
Hey, thanks, I just tried that but unfortunately it doesn't work.
20 replies
FFilament
Created by bahamagician on 1/18/2024 in #❓┊help
How to Add Custom Action Buttons to RelationManager Modal
Not quite what I was looking for. To solve this I just made the create and edit buttons redirect to the resource's create and edit pageas.
5 replies
FFilament
Created by bahamagician on 1/18/2024 in #❓┊help
How to Add Custom Action Buttons to RelationManager Modal
It looks like there's a way to attach custom action buttons to sections as headerActions. Is there another way though?
5 replies
FFilament
Created by bahamagician on 9/13/2023 in #❓┊help
Email Verification Problem
It just works now. No idea what changed or why but I'll take it.
5 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Have to add ->set('data.products', [])
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
livewire(DeliveryResource\Pages\CreateDelivery::class)
->set('data.products', [])
->fillForm([[
'products' => [
'description' => 'Test',
'qty' => 1
]],
])
->call('create')
->assertHasNoFormErrors();
livewire(DeliveryResource\Pages\CreateDelivery::class)
->set('data.products', [])
->fillForm([[
'products' => [
'description' => 'Test',
'qty' => 1
]],
])
->call('create')
->assertHasNoFormErrors();
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Figured out how to do it....
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Is there a way in the test maybe to either replace the existing empty fields in the repeater array altogether or at least get the UUID that's generated for them so I can assign values to those form fields?
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
If for example I set "->defaultItems(0)" on the repeater, then it solves my testing woes. However, I'd prefer that the UI actually does show an initial empty field, so I'd rather not have to do that.
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
So I figured out what's causing the problem but I don't know how to get around it. By default the repeater input type has a single empty item. When I use the form fill method, it's adding to that repeater array instead of replacing it completely. However, because those form fields are required, it's throwing an form error for the empty fields that are initially there.
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
No worries
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Okay, appreciate the help, thanks
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
The above error is if I'm using
'products' => [
[
'description' => 'Test',
'qty' => 1
]
],
'products' => [
[
'description' => 'Test',
'qty' => 1
]
],
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Without the key I'm back to getting the previous error which is
Tests\Feature\DeliveryResourceTest > it can create delivery
Component has errors: "data.products.9e93a0bc-373d-4608-a6f3-9c8774cbae04.description", "data.products.9e93a0bc-373d-4608-a6f3-9c8774cbae04.qty"
Failed asserting that false is true.
Tests\Feature\DeliveryResourceTest > it can create delivery
Component has errors: "data.products.9e93a0bc-373d-4608-a6f3-9c8774cbae04.description", "data.products.9e93a0bc-373d-4608-a6f3-9c8774cbae04.qty"
Failed asserting that false is true.
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
The error I'm getting now says Illegal offset type
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Nah, it's just a basic json field repeater
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Appreciate the help!
29 replies
FFilament
Created by bahamagician on 8/24/2023 in #❓┊help
How to use fillForm() with a repeater?
Thanks, I'm still getting an error but it's no longer about the products repater lol.
29 replies