0

i have on controller views page code this button:

<button
<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/1') ?>" 
class="btn btn-primary oc-icon-sign-out">export</a>
</button>

how i can get the id of this url ?

<button
<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/:id') ?>" 
class="btn btn-primary oc-icon-sign-out">export</a>
</button>

This way is not working... any ideia?

azvm
  • 41
  • 1
  • 8

1 Answers1

1

From backend we can get params but we need to use index. just use below code to get id.

$this->params[0] - will get you first param value.

<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/' . $this->params[0]) ?>"

Here index 0 denote that we want to use first param. index count starts after [param]action name and its based on 0-index. so first item has 0 index.

If your back-end controller is using Form-Controller behavior then use this answer both will work.

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

if any doubt please comment.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40
  • Hello Hardik Satasiya, i will test it, and i will leave comment. thank you! – azvm Nov 02 '19 at 12:38
  • 1
    Hello @HardikSatasiya, sorry for the big delay on saying you - Thank You - for your help, it worked! :) Stay safe! – azvm Nov 04 '20 at 13:12