如何在cakephp中通过表单操作传递id

时间:2016-07-05 07:14:24

标签: mysql controller cakephp-3.0

当我点击按钮时,我试图在last inserted id中通过表单操作传递Cakephp

我是Cakephp的新手。这是我发现的代码。你可以通过Form建议最后插入的正确方法吗?

<?php  echo $this->Html->link('View Quote', array('controller' => 'Stockcheck', 'action' => '../Quote/QuoteNo=Q1-1'), array('class' => 'button'));  ?>

QuoteNo = Q1-1应该是我最后插入的ID而QuoteNo是我的字段

2 个答案:

答案 0 :(得分:0)

试试这段代码:

echo $this->Html->link('View Quote', array('controller' => 'Stockcheck', 'action' => '../Quote/', $your_id));

如需更多帮助,请阅读此link

答案 1 :(得分:0)

<?= $this->Form->postLink('<i class="fa fa-trash-o"></i><span class="hidden-xs"> ' . __('Delete') . '</span>', ['_name' => 'delete-administrator', $administrator->id], ['confirm' => "Are you sure you want to delete {$administrator->full_name}?", 'class' => 'btn btn-sm red', 'escape' => false, 'title' => 'Delete administrator details']); ?>

<?= $this->Form->postLink('<i class="fa fa-trash-o"></i><span class="hidden-xs"> ' . __('Delete') . '</span>', ['_name' => 'edit-administrator', $administrator->id], ['class' => 'btn btn-sm red', 'escape' => false, 'title' => 'Edit administrator details']); ?>

- 使用路线名称