English 中文(简体)
Laravel Filament v3 Superior form - Autopope soil information
原标题:Laravel Filament v3 advanced form - Auto populate customer information

I m 在Laravel Filament V3建造一个表格,处理客户订单。 目前,我已经开了一个izar子。 在你选择现有客户时,我想让它自动接收地址、电子邮件和联系信息。

我审视了这些文件,我认为,指标说明是我所需要的选择,但我不敢执行。

我的法典至今为止。

return $form
        ->schema([
             FormsComponentsWizard::make([
        FormsComponentsWizardStep::make( Customer Details )
            ->schema([
                FormsComponentsSelect::make( Company Name )
                    ->required()
                    ->searchable()
                    ->getSearchResultsUsing(fn (string $search): array => Customer::where( Company Name ,  like , "%{$search}%")->limit(50)->pluck( Company Name )->toArray())
                    ->reactive(),
                FormsComponentsTextInput::make( Company Ref ),
                FormsComponentsTextInput::make( Telephone no ),
                FormsComponentsTextInput::make( Mobile No ),
                FormsComponentsTextInput::make( Email )
                ->reactive(),
                FormsComponentsTextInput::make( Contact ),
                FormsComponentsTextInput::make( Artwork Contact ),
                FormsComponentsTextInput::make( Web ),
                    ]),

还有其他一些步骤令人们感到困惑,但是他们希望首先走一步。 是否设定了正确的选择,或者有更好的办法这样做

问题回答

I think that $set would be a better option here. Also pluck the id as well so you can access the Customer Model later.

        return $form
            ->schema([
                FormsComponentsWizard::make([
                    FormsComponentsWizardStep::make( Customer Details )
                        ->schema([
                            FormsComponentsSelect::make( Company Name )
                                ->required()
                                ->searchable()
                                ->getSearchResultsUsing(fn (string $search): array => Customer::where( Company Name ,  like , "%{$search}%")->limit(50)->pluck( id , Company Name )->toArray())
                                ->live()
                                ->afterStateUpdated(function(Set $set, $state) {
                                    $customer = Customer::find($state);
                                    $set( Company Ref , $customer->CompanyRef);
                                    $set( Telephone no , $customer->TelephoneNo);
                                    $set( Mobile No , $customer->MobileNo);
                                    $set( Email , $customer->Email);
                                    $set( Contact , $customer->Contact);
                                    $set( Artwork Contact , $customer->ArtworkContact);
                                    $set( Web , $customer->Web);
                                }),
                            FormsComponentsTextInput::make( Company Ref ),
                            FormsComponentsTextInput::make( Telephone no ),
                            FormsComponentsTextInput::make( Mobile No ),
                            FormsComponentsTextInput::make( Email )
                                ->reactive(),
                            FormsComponentsTextInput::make( Contact ),
                            FormsComponentsTextInput::make( Artwork Contact ),
                            FormsComponentsTextInput::make( Web ),
                        ]),
                ])
            ]);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签