jqhph / dcat-admin

🔥 基于 Laravel 的后台系统构建工具 (Laravel Admin),使用很少的代码快速构建一个功能完善的高颜值后台系统,内置丰富的后台常用组件,开箱即用,让开发者告别冗杂的HTML代码
http://www.dcatadmin.com
MIT License
3.9k stars 713 forks source link

modal异步弹出工具表单,并且使用了tab布局,tab里的字段无法获取 #2107

Closed dahaha-365 closed 2 months ago

dahaha-365 commented 9 months ago

Description:

modal异步弹出工具表单,并且使用了tab布局,tab里的字段无法获取

Steps To Reproduce:

namespace App\Admin\Forms\Nc65;

use Dcat\Admin\Form\BlockForm;
use Dcat\Admin\Form\Field\Datetime;
use Dcat\Admin\Form\Row;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Widgets\Tab;

class PsSmTrade extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        $house = \App\Models\Nc65\FdcBdHouse::find($input['pk_house']);
        $trade = \App\Models\Nc65\PsSmTrade::with(['schedule', 'subsc', 'sign'])->find($input['pk_trade']);
        // print_r($trade);
        // $trade->schedule->vscheduledate = $input['schedule']['vscheduledate'];
        $this->pushField(new Datetime('schedule.vscheduledate'));
        print_r($this);
        print_r($input);
        //$trade->schedule()->save($input['schedule']);
        $updated = true;

        if ($updated) {
            return $this
                ->response()
                ->success('更新成功')
                ->refresh();
        } else {
            return $this->response()->error('更新失败');
        }
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->html('ddd');
        //$this->row(function(Row $form) {
        $this->hidden('pk_house');
        $this->hidden('pk_trade');
        $this->display('house.vhname');
        $this->display('trade.vtradeno');
        $this->text('sggg');
        //$this->pushField(new Datetime('schedule.vscheduledate'));
        $this->fields->push(new Datetime('schedule.vscheduledate'));

        //$this->fillFields();
        //});
        //$form = $this;
        if ($this->model()->schedule) {
            $this->tab('预订信息', function(Form $form) {
                $form->datetime('schedule.vscheduledate')->format('YYYY-MM-DD HH:mm:ss');
                $form->text('schedule.vschedulenum');
                $form->select('schedule.vdef8')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
                $form->select('schedule.vdef9')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
            });
        }
        if ($this->model()->subsc) {
            $this->tab('认购信息', function(Form $form) {
                $form->datetime('subsc.dsubscdate')->format('YYYY-MM-DD HH:mm:ss');
                $form->datetime('subsc.vdef1')->format('YYYY-MM-DD HH:mm:ss');
                $form->select('subsc.vdef8')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
                $form->select('subsc.vdef9')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
            });
        }
        if ($this->model()->sign) {
            $this->tab('签约信息', function(Form $form) {
                $form->datetime('sign.dsigndate')->format('YYYY-MM-DD HH:mm:ss');
                $form->text('sign.vcontractcno');
                $form->datetime('sign.vdef4')->format('YYYY-MM-DD HH:mm:ss');
                $form->select('sign.vdef8')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
                $form->select('sign.vdef9')->options([
                    'N' => '否',
                    'Y' => '是',
                ]);
            });
        }
    }
}

在handle方法内打印内容如下:

App\Admin\Forms\Nc65\PsSmTrade Object
(
    [view:protected] => admin::widgets.form
    [fields:protected] => Illuminate\Support\Collection Object
        (
            [items:protected] => Array
                (
                    [0] => Dcat\Admin\Form\Field\Html Object
                        (
                            [html:protected] => ddd
                            [label:protected] => 
                            [plain:protected] => 
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [column:protected] => 
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                        )

                    [1] => Dcat\Admin\Form\Field\Hidden Object
                        (
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => pk house
                            [column:protected] => pk_house
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                        )

                    [2] => Dcat\Admin\Form\Field\Hidden Object
                        (
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => pk trade
                            [column:protected] => pk_trade
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                        )

                    [3] => Dcat\Admin\Form\Field\Display Object
                        (
                            [callback:protected] => 
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => 房产名称
                            [column:protected] => house.vhname
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                        )

                    [4] => Dcat\Admin\Form\Field\Display Object
                        (
                            [callback:protected] => 
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => 交易编码
                            [column:protected] => trade.vtradeno
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                        )

                    [5] => Dcat\Admin\Form\Field\Text Object
                        (
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => sggg
                            [column:protected] => sggg
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                            [prepend:protected] => <i class="feather icon-edit-2"></i>
                            [append:protected] => 
                            [size:protected] => 
                        )

                    [6] => Dcat\Admin\Form\Field\Datetime Object
                        (
                            [format:protected] => YYYY-MM-DD HH:mm:ss
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => 预订日期
                            [column:protected] => schedule.vscheduledate
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                            [prepend:protected] => 
                            [append:protected] => 
                            [size:protected] => 
                        )

                    [7] => Dcat\Admin\Form\Field\Datetime Object
                        (
                            [format:protected] => YYYY-MM-DD HH:mm:ss
                            [value:protected] => 
                            [data:protected] => 
                            [original:protected] => 
                            [default:protected] => 
                            [allowDefaultValueInEditPage:protected] => 
                            [label:protected] => 预订日期
                            [column:protected] => schedule.vscheduledate
                            [elementName:protected] => Array
                                (
                                )

                            [elementClass:protected] => Array
                                (
                                )

                            [options:protected] => Array
                                (
                                )

                            [checked:protected] => Array
                                (
                                )

                            [script:protected] => 
                            [attributes:protected] => Array
                                (
                                )

                            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                            [parent:protected] => 
                            [view:protected] => 
                            [help:protected] => Array
                                (
                                )

                            [errorKey:protected] => 
                            [placeholder:protected] => 
                            [width:protected] => Array
                                (
                                    [label] => 2
                                    [field] => 8
                                )

                            [horizontal:protected] => 1
                            [customFormat:protected] => 
                            [display:protected] => 1
                            [labelClass:protected] => Array
                                (
                                    [0] => text-capitalize
                                )

                            [fieldClass:protected] => Array
                                (
                                )

                            [formGroupClass:protected] => Array
                                (
                                    [0] => form-field
                                )

                            [savingCallbacks:protected] => Array
                                (
                                )

                            [creationRules:protected] => Array
                                (
                                )

                            [updateRules:protected] => Array
                                (
                                )

                            [rules:protected] => Array
                                (
                                )

                            [validator:protected] => 
                            [validationMessages:protected] => Array
                                (
                                )

                            [variables:protected] => Array
                                (
                                )

                            [prepend:protected] => 
                            [append:protected] => 
                            [size:protected] => 
                        )

                )

            [escapeWhenCastingToString:protected] => 
        )

    [variables:protected] => Array
        (
        )

    [ajax:protected] => 1
    [data:protected] => Illuminate\Support\Fluent Object
        (
            [attributes:protected] => Array
                (
                )

        )

    [primaryKey:protected] => 
    [buttons:protected] => Array
        (
            [reset] => 1
            [submit] => 1
        )

    [useFormTag:protected] => 1
    [elementId:protected] => 
    [width:protected] => Array
        (
            [label] => 2
            [field] => 8
        )

    [confirm:protected] => Array
        (
        )

    [validationErrorToastr:protected] => 1
    [htmlAttributes:protected] => Array
        (
            [method] => POST
            [class] => form-horizontal
            [accept-charset] => UTF-8
            [pjax-container] => 1
        )

    [rows:protected] => Array
        (
        )

    [tab:protected] => 
    [layout:protected] => Dcat\Admin\Form\Layout Object
        (
            [form:protected] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
            [columns:protected] => Array
                (
                )

            [currentFields:protected] => Array
                (
                )

            [hasBlock:protected] => 
            [hasColumn:protected] => 
        )

    [resolvingFieldCallbacks:protected] => Array
        (
            [0] => Closure Object
                (
                    [static] => Array
                        (
                            [formData] => Array
                                (
                                    [_form_] => App\Admin\Forms\Nc65\PsSmTrade
                                )

                        )

                    [this] => App\Admin\Forms\Nc65\PsSmTrade Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$field] => <required>
                        )

                )

        )

    [currentUrl:protected] => 
)
Array
(
    [pk_house] => 0001A7100000004*****
    [pk_trade] => 0001A710000000G*****
    [sggg] => 
    [schedule] => Array
        (
            [vscheduledate] => 2024-01-01 13:11:17
        )

)

可以确认的是在tab闭包内增加的字段没有注册为母表单的fields

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.