本文整理汇总了PHP中FormHelper::_getInput方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::_getInput方法的具体用法?PHP FormHelper::_getInput怎么用?PHP FormHelper::_getInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormHelper
的用法示例。
在下文中一共展示了FormHelper::_getInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getInput
/**
* Overwrite FormHelper::_getInput()
*
* - Wrap `<div>` input element
* - Generates an input element
*
* @param array $args The options for the input element
* @return string The generated input element
*/
protected function _getInput($args)
{
$input = parent::_getInput($args);
if (!empty($this->_inputOptions['help_inline'])) {
$input .= ' ' . $this->Html->tag('span', $this->_inputOptions['help_inline'], array('class' => 'help-inline'));
}
if ($this->_inputType === 'checkbox' && $this->_inputOptions['checkboxDiv'] !== false) {
$input = $this->Html->div($this->_inputOptions['checkboxDiv'], $input);
}
$beforeInput = $this->_inputOptions['beforeInput'];
$afterInput = $this->_inputOptions['afterInput'];
$helpBlock = '';
if (!empty($this->_inputOptions['help_block'])) {
$helpBlock = $this->Html->tag('span', $this->_inputOptions['help_block'], array('class' => 'help-block'));
}
$error = null;
$errorOptions = $this->_extractOption('error', $this->_inputOptions, null);
$errorMessage = $this->_extractOption('errorMessage', $this->_inputOptions, true);
if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
$errMsg = $this->error($this->_fieldName, $errorOptions);
if ($errMsg && $errorMessage) {
$error = $errMsg;
}
}
$html = $beforeInput . $input . $afterInput . $helpBlock . $error;
if ($this->_divOptions) {
$tag = $this->_divOptions['tag'];
unset($this->_divOptions['tag']);
$html = $this->Html->tag($tag, $html, $this->_divOptions);
}
return $html;
}
示例2: _getInput
/**
* Overwrite FormHelper::_getInput()
*
* - Wrap `<div>` input element
* - Generates an input element
*
* @param array $args The options for the input element
* @return string The generated input element
*/
protected function _getInput($args)
{
$input = parent::_getInput($args);
if ($this->_inputType === 'checkbox' && $this->_inputOptions['checkboxDiv'] !== false) {
$input = $this->Html->div($this->_inputOptions['checkboxDiv'], $input);
}
$beforeInput = $this->_inputOptions['beforeInput'];
$afterInput = $this->_inputOptions['afterInput'];
$error = null;
$errorOptions = $this->_extractOption('error', $this->_inputOptions, null);
$errorMessage = $this->_extractOption('errorMessage', $this->_inputOptions, true);
if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
$errMsg = $this->error($this->_fieldName, $errorOptions);
if ($errMsg && $errorMessage) {
$error = $errMsg;
}
}
$html = $beforeInput . $input . $afterInput . $error;
if ($this->_divOptions) {
$tag = $this->_divOptions['tag'];
unset($this->_divOptions['tag']);
$html = $this->Html->tag($tag, $html, $this->_divOptions);
}
return $html;
}
示例3: _getInput
/**
* Overwrites parent method to generate a custom input.
*
* @param type $args
* @return string
*/
protected function _getInput($args)
{
$type = $this->_currentInputType = $args['type'];
$options = $this->currentInputOptions;
$customOptions = $this->currentInputOptions['custom'];
// TODO: ver esto... Si es de tipo select multiple con checkbox, no setear clase en checkoxes
if (in_array($type, array('checkbox', 'hidden')) || $args['type'] == 'select' && isset($args['options']['multiple']) && $args['options']['multiple'] == 'checkbox' && $args['options']['class'] == 'form-control') {
unset($args['options']['class']);
}
// Render input field via parent method
$input = parent::_getInput($args);
if ($type == 'hidden') {
return $input;
}
// Prepend beforeInput and append afterInput to generated input field
$html['input'] = $this->_getCustom('beforeInput') . $input . $this->_getCustom('afterInput');
// Checkbox label rendering
if ($type == 'checkbox') {
if ($this->_getCustom('checkboxLabel')) {
$options = $this->domId($args);
$html['input'] .= ' ' . $customOptions['checkboxLabel'];
$html['input'] = $this->Html->tag('label', $html['input'], array('for' => $options['id']));
}
$html['input'] = $this->Html->tag('div', $html['input'], array('class' => 'checkbox'));
}
// Error rendering, overwrites parent rendering
$html['error'] = null;
$errorOptions = $this->_extractOption('error', $options, null);
if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
$html['error'] = $this->error($this->_fieldName, $errorOptions);
}
// Help block rendering
$html['help'] = null;
if (!empty($customOptions['help'])) {
$html['help'] = $this->Html->tag('div', $customOptions['help'], array('class' => 'help-block'));
}
// Set size of input if enabled, and get full html of input and block
if (!empty($customOptions['wrap'])) {
if ($customOptions['externalWrap']) {
$html['input'] = $this->Html->tag('div', $html['input'], array('class' => $customOptions['wrap']));
$html['input'] = $this->Html->tag('div', $html['input'], array('class' => 'row'));
if ($customOptions['externalWrap']) {
$fullHtml = $html['input'] . $html['error'] . $html['help'];
$fullHtml = $this->Html->tag('div', $fullHtml, array('class' => $customOptions['externalWrap']));
}
} else {
$fullHtml = $html['input'] . $html['error'] . $html['help'];
$fullHtml = $this->Html->tag('div', $fullHtml, array('class' => $customOptions['wrap']));
}
} else {
$fullHtml = $html['input'] . $html['error'] . $html['help'];
}
return $fullHtml;
}