十月CMS |在控制器中,在preview.htm上创建编辑按钮,然后链接到具有相同ID的update.htm [英] October CMS | In the controller, create edit button on preview.htm which then links to update.htm with the same ID
问题描述
所以我想做的是,从后端单击一个列表项,然后将您带到/mymodel/preview/id,而不是带您到/mymodel/update/id.预览页面上将有一个按钮,可带您进入/mymodel/update/id,该ID与/mymodel/preview/id匹配.
So what I want to do is, from the backend, click on a list item which then, rather than take you to /mymodel/update/id, it takes you to /mymodel/preview/id. The preview page will then have a button which takes you to /mymodel/update/id which matches the ID as /mymodel/preview/id.
我已经通过使用'recordUrl:'namespace/myplugin/mymodel/preview/:id'更改config_list.yaml来实现第一部分.
I have achieved the first part by changing the config_list.yaml by using 'recordUrl: 'namespace/myplugin/mymodel/preview/:id'.'
但是,我似乎找不到一种可以使按钮知道当前预览ID的方法,该按钮会将我带到相同的ID,但使用/update/id而不是Preview/id.
However, I cannot seem to find a way to make a button which is then aware of the ID of the current preview which would take me to the same ID but /update/id rather than preview/id.
我这样做的目的是,当人们只想查看记录时,他们在查看详细信息时不会意外更改某些东西.
I am doing this so when people just want to view a record, they don't accidentally change something when just viewing details.
推荐答案
您可以使用$formModel
,因为Form Behavior
会将其注入以便查看.
You can use $formModel
as Form Behavior
will inject it to view.
<a
href="<?= Backend::url('author/plugin/your_controller/update/'.$formModel->id) ?>"
class="btn btn-primary oc-icon-pencil">
Edit
</a>
您可以在工具栏中添加此标记,以将用户重定向到编辑模式.
You can add this markup in your toolbar to redirect user to edit mode.
如有疑问,请发表评论.
if any doubt please comment.
这篇关于十月CMS |在控制器中,在preview.htm上创建编辑按钮,然后链接到具有相同ID的update.htm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!