CakePHP的2.5 Postlink hidding模型属性附加伤害名字我使用一个视图文件内CakePHP的2.5 postlink方法在URL
问题描述:
:CakePHP的2.5 Postlink hidding模型属性附加伤害名字我使用一个视图文件内CakePHP的2.5 postlink方法在URL
$tableRow['Model.modelatribute'] = $this->Form->postLink(
$data['Vehicle']['plate'],
array('controller'=>'somecontroller',
'action' => 'somemethod',
'Model.modelatribute' => base64_encode($data['Vehicle']['plate'])
),
array('confirm' => 'Look at vehicle '.$data['Vehicle']['plate'])
);
我想不显示的URL栏上的模型属性附加伤害名。点击链接和被重定向后,URL显示:
somemethod/Model.modelatribute:vSpEeTIweQ%3D%3D
我可以隐藏模型属性附加伤害的名称,使用方法postlinkØCakePHP的2.5?
Thank's提前
答
如果您只是想将Model.modelatribute
的值作为参数传递,请将Model.modelatribute放在您的routing array中。如果你想传递值而不需要在url中找到,你可以使用postlink的data option。
echo $this->Form->postLink(
$data['Vehicle']['plate'],
array(
'controller'=>'somecontroller',
'action' => 'somemethod',
base64_encode($data['Vehicle']['plate']) // Routing array without modelname
),
array(
'confirm' => 'Look at vehicle '.$data['Vehicle']['plate'],
'data' => array(
// Data option of postLink method
'Model.modelatribute' => base64_encode($data['Vehicle']['plate'])
)
)
);
答
好,你摆在那里。如果你不希望它在那里,只是不要把它放在URL中。您可以选择put it into the body of the POST request。
如果您担心人们可以将模型名称用于某些事情,并且出于这个原因想隐藏它,那么这是一种非常糟糕的方法,称为security through obscurity。相反,您需要确保您验证只传递并处理了您想要的值。因此,请始终从任何地方检查您的传入数据。