首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Laravel Backpack的CRUD数据未显示在自定义操作表单上

Laravel Backpack的CRUD数据未显示在自定义操作表单上
EN

Stack Overflow用户
提问于 2021-02-13 17:07:54
回答 1查看 425关注 0票数 1

我已经对Backpack进行了一段时间的修补,并试图创建一个名为"Next Process“的自定义操作。基本上,此操作只是一个“编辑”函数,需要填充不同的字段(因为我们希望"create“函数上的字段也被编辑,”下一步“的填充将在创建数据后完成。因此,我们不希望只利用提供的CRUD Edit特征)。

问题是,我无法在这个自定义函数的表单上显示字段的值。如果我们尝试从头开始填充表单(没有现有数据),页面就可以正常工作。该值已存储,并可在"show“页面上查看。但是,当我们再次尝试转到"Next Process“页面时(现在该字段已填充了一些数据),现有数据不会显示。现在更新表单会将所有现有数据重置为空,除了我们刚才填充的字段。

我在函数的开头包含了$this->data['crud'] = $his->crud$this->data['entry'] = $this->crud->getEntry($id),并将$data传递给了视图。视图本身只是来自Backpack自己的模板的“编辑”刀片的发布版本。

我还尝试使用$this->view->getEditCrud() (以防发布的模板是罪魁祸首),但结果仍然是一样的。

这有什么问题呢?我附上我的代码以供参考。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public function getProcess($id)
      {
          $this->crud->hasAccessOrFail('update');
          $this->crud->setOperation('process');
          $this->crud->setHeading('Process '.$this->crud->entity_name, 'getProcess'); // set the Heading for the create action
          $this->crud->setSubheading('Process '.$this->crud->entity_name, 'getProcess'); // set the Subheading for the create action
          $this->data['breadcrumbs'] = [
            trans('backpack::crud.admin') => backpack_url('dashboard'),
            $this->crud->entity_name_plural => url($this->crud->route),
            'Process '.$this->crud->entity_name => false
        ];
          // get the info for that entry
          $this->data['entry'] = $this->crud->getEntry($id);
          $this->data['crud'] = $this->crud;
          $this->data['title'] = 'Process '.$this->crud->entity_name;
          $this->data['id'] = $id;
          $this->crud->getEntry($id);

          $this->crud->addField([
              'name' => 'support_type',
              'label' => 'Support type',
          ]);

          // Redacted: Whole bunch of addField with the 'name' matching the database column's name 
          // (pretty sure it's not the problem since saving the form updates the specific field 
          // in the database).
          

        $this->crud->addField([
            'name' => 'third_pty_partnership',
            'label' => 'Third Party Partnerships',
        ]);


        $this->data['saveAction'] = [
            "active" => [
                "value" => "save_and_back",
                "label" => "Save and go back"
            ],
            "options" => [

            ]
            ];

          return view('vendor.backpack.crud.processForm', $this->data);
      }

提前感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2021-09-11 06:33:06

将addFields放在对条目信息的调用之前。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66187733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文