本文整理匯總了PHP中Csrf::generate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Csrf::generate方法的具體用法?PHP Csrf::generate怎麽用?PHP Csrf::generate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Csrf
的用法示例。
在下文中一共展示了Csrf::generate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
function render(Container $form, $data, $prefix = '')
{
if ($form->if) {
$this->pushStack(new Test($prefix . $form->if), $data);
}
// Add the forms prefix on
$prefix .= $form->prefix;
// Group by the form name if it is set
if ($form->name) {
if (isset($data[$form->name])) {
$data = $data[$form->name];
} else {
$data = array();
}
}
// Render the <form> tag if it has an action
if ($form->action) {
print '<form' . Html::attributes(array('id' => $form->id, 'action' => $form->action, 'method' => $form->method, 'enctype' => $form->upload ? 'multipart/form-data' : NULL)) . '>' . "\n";
// Send a _csrf field with the form
print '<input' . Html::attributes(array('type' => 'hidden', 'name' => '_csrf', 'value' => Csrf::generate($form->intent, $form->expire))) . '>' . "\n";
}
// Render each of the elements
foreach ($form->getElements() as $element) {
$this->renderElement($element, $data, $prefix);
}
// Kill anything remaining on the stack
$this->endStack(NULL);
// Close the actual form
if ($form->action) {
print '</form>' . "\n";
}
}