October CMS | In the controller, create edit button on preview.htm which then links to update.htm with the same ID

不羁的心 提交于 2020-01-25 06:47:31

问题


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.

I have achieved the first part by changing the config_list.yaml by using 'recordUrl: 'namespace/myplugin/mymodel/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.


回答1:


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.



来源:https://stackoverflow.com/questions/58451425/october-cms-in-the-controller-create-edit-button-on-preview-htm-which-then-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!