我已经对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()
(以防发布的模板是罪魁祸首),但结果仍然是一样的。
这有什么问题呢?我附上我的代码以供参考。
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);
}
提前感谢您的帮助!
发布于 2021-09-11 06:33:06
将addFields放在对条目信息的调用之前。
https://stackoverflow.com/questions/66187733
复制相似问题