本文整理汇总了PHP中AppHelper::_initInputField方法的典型用法代码示例。如果您正苦于以下问题:PHP AppHelper::_initInputField方法的具体用法?PHP AppHelper::_initInputField怎么用?PHP AppHelper::_initInputField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppHelper
的用法示例。
在下文中一共展示了AppHelper::_initInputField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initInputField
/**
* Sets field defaults and adds field to form security input hash.
* Will also add a 'form-error' class if the field contains validation errors.
*
* ### Options
*
* - `secure` - boolean whether or not the field should be added to the security fields.
* Disabling the field using the `disabled` option, will also omit the field from being
* part of the hashed key.
*
* This method will convert a numerically indexed 'disabled' into a associative
* value. FormHelper's internals expect associative options.
*
* @param string $field Name of the field to initialize options for.
* @param array $options Array of options to append options into.
* @return array Array of options for the input.
*/
protected function _initInputField($field, $options = array()) {
if (isset($options['secure'])) {
$secure = $options['secure'];
unset($options['secure']);
} else {
$secure = (isset($this->request['_Token']) && !empty($this->request['_Token']));
}
$disabledIndex = array_search('disabled', $options, true);
if (is_int($disabledIndex)) {
unset($options[$disabledIndex]);
$options['disabled'] = true;
}
$result = parent::_initInputField($field, $options);
if ($this->tagIsInvalid() !== false) {
$result = $this->addClass($result, 'form-error');
}
if (!empty($result['disabled']) || $secure === self::SECURE_SKIP) {
return $result;
}
if (!isset($result['required']) &&
$this->_introspectModel($this->model(), 'validates', $this->field())
) {
$result['required'] = true;
}
$this->_secure($secure, $this->_secureFieldName($options));
return $result;
}
示例2: _initInputField
/**
* Sets field defaults and adds field to form security input hash
*
* ### Options
*
* - `secure` - boolean whether or not the field should be added to the security fields.
*
* @param string $field Name of the field to initialize options for.
* @param array $options Array of options to append options into.
* @return array Array of options for the input.
*/
protected function _initInputField($field, $options = array())
{
if (isset($options['secure'])) {
$secure = $options['secure'];
unset($options['secure']);
} else {
$secure = isset($this->request['_Token']) && !empty($this->request['_Token']);
}
$fieldName = null;
if ($secure && !empty($options['name'])) {
preg_match_all('/\\[(.*?)\\]/', $options['name'], $matches);
if (isset($matches[1])) {
$fieldName = $matches[1];
}
}
$result = parent::_initInputField($field, $options);
if ($secure) {
$this->__secure($fieldName);
}
return $result;
}
示例3: array
/**
* Sets field defaults and adds field to form security input hash
*
* Options
*
* - `secure` - boolean whether or not the the field should be added to the security fields.
*
* @param string $field Name of the field to initialize options for.
* @param array $options Array of options to append options into.
* @return array Array of options for the input.
* @access protected
*/
function _initInputField($field, $options = array())
{
if (isset($options['secure'])) {
$secure = $options['secure'];
unset($options['secure']);
} else {
$secure = isset($this->params['_Token']) && !empty($this->params['_Token']);
}
$result = parent::_initInputField($field, $options);
if ($secure) {
$this->__secure();
}
return $result;
}
示例4: _initInputField
/**
* Sets field defaults and adds field to form security input hash
*
* ### Options
*
* - `secure` - boolean whether or not the field should be added to the security fields.
* Disabling the field using the `disabled` option, will also omit the field from being
* part of the hashed key.
*
* @param string $field Name of the field to initialize options for.
* @param array $options Array of options to append options into.
* @return array Array of options for the input.
*/
protected function _initInputField($field, $options = array())
{
if (isset($options['secure'])) {
$secure = $options['secure'];
unset($options['secure']);
} else {
$secure = isset($this->request['_Token']) && !empty($this->request['_Token']);
}
$result = parent::_initInputField($field, $options);
if ($this->tagIsInvalid() !== false) {
$result = $this->addClass($result, 'form-error');
}
if (!empty($result['disabled']) || $secure === self::SECURE_SKIP) {
return $result;
}
$fieldName = null;
if (!empty($options['name'])) {
preg_match_all('/\\[(.*?)\\]/', $options['name'], $matches);
if (isset($matches[1])) {
$fieldName = $matches[1];
}
}
$this->_secure($secure, $fieldName);
return $result;
}
示例5: _initInputField
/**
* Sets field defaults and adds field to form security input hash.
* Will also add a 'form-error' class if the field contains validation errors.
*
* ### Options
*
* - `secure` - boolean whether or not the field should be added to the security fields.
* Disabling the field using the `disabled` option, will also omit the field from being
* part of the hashed key.
*
* This method will convert a numerically indexed 'disabled' into an associative
* value. FormHelper's internals expect associative options.
*
* @param string $field Name of the field to initialize options for.
* @param array $options Array of options to append options into.
*
* @return array Array of options for the input.
*/
protected function _initInputField($field, $options = array())
{
if (isset($options['secure'])) {
$secure = $options['secure'];
unset($options['secure']);
} else {
$secure = isset($this->request['_Token']) && !empty($this->request['_Token']);
}
$disabledIndex = array_search('disabled', $options, TRUE);
if (is_int($disabledIndex)) {
unset($options[$disabledIndex]);
$options['disabled'] = TRUE;
}
$result = parent::_initInputField($field, $options);
if ($this->tagIsInvalid() !== FALSE) {
$result = $this->addClass($result, 'form-error');
}
$isDisabled = FALSE;
if (isset($result['disabled'])) {
$isDisabled = $result['disabled'] === TRUE || $result['disabled'] === 'disabled' || is_array($result['disabled']) && !empty($result['options']) && array_diff($result['options'], $result['disabled']) === array();
}
if ($isDisabled) {
return $result;
}
if (!isset($result['required']) && $this->_introspectModel($this->model(), 'validates', $this->field())) {
$result['required'] = TRUE;
}
if ($secure === static::SECURE_SKIP) {
return $result;
}
$this->_secure($secure, $this->_secureFieldName($options));
return $result;
}