Cake\View\Helper\FormHelper::secure PHP Метод

secure() публичный Метод

If $secureAttributes is set, these HTML attributes will be merged into the hidden input tags generated for the Security Component. This is especially useful to set HTML5 attributes like 'form'.
public secure ( array $fields = [], array $secureAttributes = [] ) : string
$fields array If set specifies the list of fields to use when generating the hash, else $this->fields is being used.
$secureAttributes array will be passed as HTML attributes into the hidden input elements generated for the Security Component.
Результат string A hidden input field with a security hash, or empty string when secured forms are not in use.
    public function secure(array $fields = [], array $secureAttributes = [])
    {
        if (empty($this->request['_Token'])) {
            return '';
        }
        $debugSecurity = Configure::read('debug');
        if (isset($secureAttributes['debugSecurity'])) {
            $debugSecurity = $debugSecurity && $secureAttributes['debugSecurity'];
            unset($secureAttributes['debugSecurity']);
        }
        $secureAttributes['secure'] = static::SECURE_SKIP;
        $tokenData = $this->_buildFieldToken($this->_lastAction, $fields, $this->_unlockedFields);
        $tokenFields = array_merge($secureAttributes, ['value' => $tokenData['fields']]);
        $out = $this->hidden('_Token.fields', $tokenFields);
        $tokenUnlocked = array_merge($secureAttributes, ['value' => $tokenData['unlocked']]);
        $out .= $this->hidden('_Token.unlocked', $tokenUnlocked);
        if ($debugSecurity) {
            $tokenDebug = array_merge($secureAttributes, ['value' => urlencode(json_encode([$this->_lastAction, $fields, $this->_unlockedFields]))]);
            $out .= $this->hidden('_Token.debug', $tokenDebug);
        }
        return $this->formatTemplate('hiddenBlock', ['content' => $out]);
    }