diff --git a/src/builder/FormBuilder.php b/src/builder/FormBuilder.php index 830fbf7..087c5b5 100644 --- a/src/builder/FormBuilder.php +++ b/src/builder/FormBuilder.php @@ -21,7 +21,7 @@ class FormBuilder { - use Builder; + protected $modelClass = ''; /** * style * @var array @@ -68,7 +68,8 @@ public static function instance($options = []) public function __construct($options=[]) { $this->template = $options['template']??'../../../vendor/funadmin/fun-addons/src/builder/layout/add'; -; + $this->modelClass = $this->modelClass?: ($config['model'] ?? ($config['modelClass'] ?? '')); + } /** @@ -576,15 +577,14 @@ public function style(string $name,$options=[]){ */ public function assign($data=[]){ $form = $this; - View::assign([ + View::assign(array_merge([ 'formBuilder'=>$form, 'formStyle'=>implode('',$this->style), 'formLink'=>implode('',$this->link), 'formScript'=>implode('',$this->script), 'formJs'=>implode('',$this->js), 'formHtml'=>implode('',$this->formHtml), - 'formData'=>$data, - ]); + ],$data)); return $this; } diff --git a/src/builder/TableBuilder.php b/src/builder/TableBuilder.php index bf6a93b..69f3c3f 100644 --- a/src/builder/TableBuilder.php +++ b/src/builder/TableBuilder.php @@ -126,7 +126,7 @@ private function __construct(array $config = []) $this->fields = $config['fields'] ?? []; // 初始化 $this->template = $config['template'] ?? '../../../vendor/funadmin/fun-addons/src/builder/layout/table'; - $this->modelClass = $config['model'] ?? ($config['modelClass'] ?? ''); + $this->modelClass = $this->modelClass?: ($config['model'] ?? ($config['modelClass'] ?? '')); $this->driver = $config['driver'] ?? 'mysql'; $this->tablePrefix = config('database.connections.' . $this->driver . '.prefix'); $this->database = Config::get('database.connections' . '.' . $this->driver . '.database'); @@ -591,7 +591,7 @@ public function toolbar($buttons = [], string $tableId = 'list') */ public function assign(array $data = []) { - View::assign([ + View::assign(array_merge([ 'node' => implode(' ', $this->node), 'options' => $this->options, 'requests' => $this->requests, @@ -600,8 +600,7 @@ public function assign(array $data = []) 'extraJs' => $this->extraJs, 'tableStyle' => $this->style, 'tableLink' => $this->link, - 'data' => $data, - ]); + ],$data)); return $this; }