Perforce Chronicle 2012.2/486814
API Documentation
|
Inserts the form's csrf token as a hidden input (provided the form has csrf protection enabled). More...
Public Member Functions | |
render ($content) | |
If the csrf protection has been enabled, add a hidden field to the form. |
Inserts the form's csrf token as a hidden input (provided the form has csrf protection enabled).
P4Cms_Form_Decorator_Csrf::render | ( | $ | content | ) |
If the csrf protection has been enabled, add a hidden field to the form.
string | $content | previously rendered content string, may be empty |
{ // only take effect for forms with csrf protection enabled. $form = $this->getElement(); if (!$form instanceof P4Cms_Form || !$form->hasCsrfProtection()) { return $content; } // Cancel page caching as we are using a CSRF token. if (P4Cms_Cache::canCache('page')) { P4Cms_Cache::getCache('page')->cancel(); } // generate hidden csrf token field. $html = '<input type="hidden" name="' . P4Cms_Form::CSRF_TOKEN_NAME . '" value="' . P4Cms_Form::getCsrfToken() . '" />'; return $this->getPlacement() == static::APPEND ? $content . $this->getSeparator() . $html : $html . $this->getSeparator() . $content; }