Help me to select address from address list in modal

I have created
class AddressForm extends Field
class AddressForm extends Field
in this Created an action
Forms\Components\TextInput::make("name")
->label("Name / Company Name")
->maxLength(50)
->suffixAction(
Action::make('select_address')
->icon('heroicon-o-magnifying-glass')
->action(function (callable $get) {
$customer_id = $get('../customer_id');
if (!$customer_id) {
Notification::make()
->danger()
->title('Please select customer First')
->send();

return;
}
})
->modalContent(function (callable $get) {
$customer_id = $get('../customer_id');
return view('filament.addresses.view', compact('customer_id'));
})
->modalSubmitAction(false)
->modalWidth('7xl')
)->inlineSuffix(),
Forms\Components\TextInput::make("name")
->label("Name / Company Name")
->maxLength(50)
->suffixAction(
Action::make('select_address')
->icon('heroicon-o-magnifying-glass')
->action(function (callable $get) {
$customer_id = $get('../customer_id');
if (!$customer_id) {
Notification::make()
->danger()
->title('Please select customer First')
->send();

return;
}
})
->modalContent(function (callable $get) {
$customer_id = $get('../customer_id');
return view('filament.addresses.view', compact('customer_id'));
})
->modalSubmitAction(false)
->modalWidth('7xl')
)->inlineSuffix(),
my view blade file
@php
$widgetData = [
'inModal' => true,
'customer_id' => $customer_id,
];
@endphp

<x-filament-widgets::widgets :widgets="[\App\Filament\Widgets\AddressListWidget::class]" :columns="1" :data="$widgetData" />
@php
$widgetData = [
'inModal' => true,
'customer_id' => $customer_id,
];
@endphp

<x-filament-widgets::widgets :widgets="[\App\Filament\Widgets\AddressListWidget::class]" :columns="1" :data="$widgetData" />
Created Table widget with
protected function getTableActions(): array
{
return [
Tables\Actions\Action::make('select')
->label('Select')
->action(function ($record) {
$this->emit('addressSelected', $record);
})
->icon('heroicon-o-check'),
];
}
protected function getTableActions(): array
{
return [
Tables\Actions\Action::make('select')
->label('Select')
->action(function ($record) {
$this->emit('addressSelected', $record);
})
->icon('heroicon-o-check'),
];
}
Please Help me to use record to address form
6 Replies
Hitesh Makwana
Hitesh MakwanaOP3mo ago
Here What I exactly want that I have my addresses with relation to customer In Quotation Form I want to give manual enter address as well and also user can select address from customer's address When user click on search icon user will see modal with list of customer's address from the customer's address listed in table with an action button "use address" I want to use all record to fill in the forms I mention all codes above
Hitesh Makwana
Hitesh MakwanaOP3mo ago
GitHub
demo/app/Forms/Components/AddressForm.php at main · filamentphp/demo
Source code for the demo.filamentphp.com website. Contribute to filamentphp/demo development by creating an account on GitHub.
Matthew
Matthew3mo ago
There is a complexity in having the list of addresses in a modal. Easier to have them in a select dropdown, which can be searchable. Then using https://filamentphp.com/docs/3.x/forms/advanced#field-updates ($get and $set), you can populate your address element from the selected drop down.
Hitesh Makwana
Hitesh MakwanaOP3mo ago
Thank you for you respond I have populated address list in table in modal I have created action in that widget too now is there any option that I can handle that click in my AddressForm class?
Matthew
Matthew3mo ago
Probably, unfortunately difficult to tell without your all your code.

Did you find this page helpful?