0

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 Answers1

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.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40