本文整理汇总了PHP中FormHelper::input方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::input方法的具体用法?PHP FormHelper::input怎么用?PHP FormHelper::input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormHelper
的用法示例。
在下文中一共展示了FormHelper::input方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: input
public function input($fieldName, $options = array())
{
if (isset($options['label']) && (!isset($options['label']['class']) || !empty($options['label']['class']))) {
$options['label'] = array('class' => 'col-lg-2 control-label', 'text' => $options['label']);
}
return parent::input($fieldName, $options);
}
示例2: input
function input($fieldName, $options = array())
{
if (isset($options['type']) && $options['type'] == 'hidden') {
return parent::input($fieldName, $options);
}
return $this->divWrap(parent::input($fieldName, $options));
}
示例3: input
/**
* Input redefinition - required class += required span
* @link http://book.cakephp.org/view/1390/Automagic-Form-Elements
*/
function input($fieldName, $options = array())
{
if (isset($options['class']) && strstr('required', $options['class'])) {
$options['label'] .= $this->required();
}
return parent::input($fieldName, $options) . "\n";
}
示例4: input
public function input($fieldName, $options = array()) {
if (!empty($options['type']) and ($options['type'] == 'submit')) {
if ((!empty($options['label'])) and is_array($options['label'])) {
$label['class'] = (!empty($label['class']))? 'control-label col-sm-2 '.$options['label']: 'control-label col-sm-2';
$label['text'] = (!empty($label['text']))? $options['label']['text']: false;
} else if (!empty($options['label'])) {
$label['text'] = false;
$label['class'] = 'control-label col-sm-2';
}
if (isset($label)) {
$options['label'] = $label;
}
if (empty($options['class'])) $options['class'] = 'btn btn-danger';
} else {
if (!empty($options['class'])) $options['class'] = 'form-control '.$options['class'];
if ((!empty($options['label'])) and is_array($options['label'])) {
$options['label']['class'] = (!empty($options['label']['class']))? 'control-label col-sm-2 '.$options['label']['class']: 'control-label col-sm-2';
} else if (!empty($options['label'])) {
$label['text'] = $options['label'];
$label['class'] = 'control-label col-sm-2';
$options['label'] = $label;
}
}
if (empty($options['between'])) $options['between'] = '<div class="col-sm-10">';
if (!empty($options['after'])) $options['after'] = $options['after'].'</div></div> ';
return parent::input($fieldName, $options);
}
示例5: input
/**
* Adds Bootstrap-style class name to datetime inputs
* @param string $fieldName
* @param array $options
* @return string
*/
public function input($fieldName, $options = array())
{
if (!isset($options['multiple'])) {
// TODO : find a way to make select multiple change into multiple checkboxes
// $options['multiple'] = 'checkbox';
}
if (!isset($options['type'])) {
$modelKey = $this->model();
$fieldKey = $this->field();
$fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey);
if (is_null($fieldDef)) {
$options['multiple'] = 'checkbox';
} else {
if ($fieldDef['type'] == 'datetime') {
// Add "input-small" to class attribute
if (isset($options['class'])) {
$classes = explode(' ', $options['class']);
$classes[] = 'input-medium';
$options['class'] = implode(' ', $classes);
} else {
$options['class'] = 'input-medium';
}
}
}
} else {
if ($options['type'] == 'quantity') {
$options['type'] = 'number';
$options['pattern'] = '^[0-9]\\d*$';
}
}
return parent::input($fieldName, $options);
}
示例6: input
function input($fieldName, $options = array())
{
if (!empty($this->params['named']) && !empty($this->params['named'][$fieldName])) {
$options['value'] = $this->params['named'][$fieldName];
}
$fieldType = $fieldName;
$pos = strrpos($fieldType, '.');
if (!($pos === false)) {
$fieldType = substr($fieldType, $pos + 1);
}
switch ($fieldType) {
case "file":
case "movie":
case "image":
case "thumbnail":
case "thumb":
case "logo":
case "afbeelding":
case "foto":
case "photo":
$options['type'] = 'file';
break;
}
return parent::input($fieldName, $options);
}
示例7: input
public function input($fieldName, $options = array())
{
$defaults = array('before' => '', 'between' => '<div class="controls">', 'after' => '</div>', 'format' => array('before', 'label', 'between', 'input', 'error', 'after'), 'class' => $this->formSpan, 'div' => array('class' => 'control-group'), 'error' => array('attributes' => array('class' => 'help-block error', 'wrap' => 'span')), 'help' => '', 'required' => false, 'append' => array(), 'prepend' => array());
$options = array_merge($defaults, $this->_inputDefaults, $options);
if (isset($options['type']) && $options['type'] == 'radio') {
$options['between'] = $options['after'] = '';
}
if (isset($options['help'])) {
$options['after'] = '<p class="help-block">' . $options['help'] . '</p>' . $options['after'];
unset($options['help']);
}
if (isset($options['actions'])) {
$options['after'] .= '<div class="actions">' . join("\n", $options['actions']) . '</div>';
unset($options['actions']);
}
if (!empty($options['prepend']) && empty($options['append'])) {
$prepend = is_array($options['prepend']) ? join("\n", $options['prepend']) : '<span class="add-on">' . $options['prepend'] . '</span>';
$options['between'] .= '<div class="input-prepend">' . $prepend;
$options['after'] = '</div>' . $options['after'];
unset($options['prepend']);
} elseif (!empty($options['append']) && empty($options['prepend'])) {
$append = is_array($options['append']) ? join("\n", $options['append']) : '<span class="add-on">' . $options['append'] . '</span>';
$options['between'] .= '<div class="input-append">';
$options['after'] = $append . '</div>' . $options['after'];
unset($options['append']);
} elseif (!empty($options['prepend']) && !empty($options['append'])) {
$prepend = is_array($options['prepend']) ? join("\n", $options['prepend']) : '<span class="add-on">' . $options['prepend'] . '</span>';
$append = is_array($options['append']) ? join("\n", $options['append']) : '<span class="add-on">' . $options['append'] . '</span>';
$options['between'] .= '<div class="input-append input-prepend">' . $prepend;
$options['after'] = $append . '</div>' . $options['after'];
unset($options['prepend']);
unset($options['append']);
}
return parent::input($fieldName, $options);
}
示例8: input
function input($fieldName, $options = array())
{
if (ClassRegistry::isKeySet($this->model())) {
$model =& ClassRegistry::getObject($this->model());
if ($model->isOrigamiColumn($fieldName)) {
$type = $model->getOrigamiColumnType($fieldName);
if (method_exists($this, $type)) {
unset($options['type']);
// We are specifying the type, so we need to remove any user specified types
$out = $this->{$type}($fieldName, $options);
// The code is this section is mostly copied from the cake php
// FormHelper input method
$div = true;
$divOptions = array();
if (array_key_exists('div', $options)) {
$div = $options['div'];
unset($options['div']);
}
if (!empty($div)) {
$divOptions['class'] = 'input';
$divOptions = $this->addClass($divOptions, $type);
if (is_string($div)) {
$divOptions['class'] = $div;
} elseif (is_array($div)) {
$divOptions = array_merge($divOptions, $div);
}
if (in_array($this->field(), $this->fieldset['validates'])) {
$divOptions = $this->addClass($divOptions, 'required');
}
if (!isset($divOptions['tag'])) {
$divOptions['tag'] = 'div';
}
}
if ($type != 'hidden') {
$error = null;
if (isset($options['error'])) {
$error = $options['error'];
unset($options['error']);
}
if ($error !== false) {
$errMsg = $this->error($fieldName, $error);
if ($errMsg) {
$out .= $errMsg;
$divOptions = $this->addClass($divOptions, 'error');
}
}
}
if (isset($divOptions) && isset($divOptions['tag'])) {
$tag = $divOptions['tag'];
unset($divOptions['tag']);
$out = $this->Html->tag($tag, $out, $divOptions);
}
// end cake php inputs copy
return $out;
}
}
}
return parent::input($fieldName, $options);
}
示例9: tweet
/**
* create tweet box
*
* @param $fieldName
* @param $options
* type: element type (default: textarea)
* maxLength: text max length (default: 140)
* counterText: length message
* submit: submit button message. if set to false, not create.
* jqueryCharCount: path to charCount.js (jquery plugin)
* other keys set to input element options.
*/
public function tweet($fieldName, $options = array())
{
$this->setEntity($fieldName);
$domId = !empty($options['id']) ? $options['id'] : $this->domId($fieldName);
$default = array('type' => 'textarea', 'maxlength' => 140, 'jqueryCharCount' => '/twitter_kit/js/charCount.js', 'counterText' => __d('twitter_kit', 'Characters left: ', true), 'submit' => __d('twitter_kit', 'Tweet', true));
$options = am($default, $options);
$inputOptions = $options;
unset($inputOptions['jqueryCharCount']);
unset($inputOptions['counterText']);
unset($inputOptions['submit']);
$out = $this->Html->script($options['jqueryCharCount']);
$out .= $this->Form->input($fieldName, $inputOptions);
$out .= $this->Js->buffer("\n \$('#{$domId}').charCount({\n limit: {$options['maxlength']},\n counterText: '{$options['counterText']}',\n exceeded: function(element) {\n \$('#{$domId}Submit').attr('disabled', true);\n },\n allowed: function(element) {\n \$('#{$domId}Submit').removeAttr('disabled');\n }\n });\n ");
if ($options['submit']) {
$out .= $this->Form->submit($options['submit'], array('id' => $domId . 'Submit'));
}
return $this->output($out);
}
示例10: input
public function input($fieldName, $options = array())
{
$this->setEntity($fieldName);
$model = $this->_getModel($this->model());
$fieldKey = $this->field();
if (!@$options['type'] && $model->hasMethod('cloudinaryFields') && in_array($fieldKey, $model->cloudinaryFields())) {
$options['type'] = 'file';
}
return parent::input($fieldName, $options);
}
示例11: input
public function input($fieldName, $options = array())
{
$this->setEntity($fieldName);
$options = $this->_parseOptions($options);
if ($options['type'] == 'checkbox') {
$options['format'] = array('before', 'label', 'between', 'input', 'after', 'error');
} elseif ($options['type'] == 'text' || $options['type'] == 'textarea') {
$options = array_merge(array('class' => 'input-xxlarge'), $options);
}
return parent::input($fieldName, $options);
}
示例12: input
public function input($fieldName, $options = array())
{
$options += $this->_inputDefaults + array('div' => 'form-field', 'class' => 'input-text medium', 'error' => array('attributes' => array('wrap' => 'small')));
if ($options['class'] !== 'input-text') {
$options['class'] .= ' input-text';
}
if (!empty($options['error']) && empty($options['error']['attributes']['wrap'])) {
$options['error']['attributes']['wrap'] = 'small';
}
return parent::input($fieldName, $options);
}
示例13: editor
/**
* Create a input with CKEditor
*
* @param string $name - field name
* @param array $options - input options
* @return string
*/
public function editor($fieldName, $options = array())
{
$this->Html->script('vendor/ckeditor/ckeditor', array('inline' => false));
$this->Html->css('/js/vendor/ckeditor/fixes', array('inline' => false));
$options = array_merge(array('class' => 'ckeditor'), $options);
//
// $options['class'] = 'ckeditor '.$options['class'];
if (isset($options['fullwidth']) && $options['fullwidth']) {
return '<div class="control-group"><div class="clearfix"></div><div class="shadow text-center">' . $this->textarea($fieldName, $options) . '</div></div>';
}
return parent::input($fieldName, $options);
}
示例14: input
public function input($fieldName, $options = array())
{
$fieldNameShort = $fieldName;
if (strstr($fieldName, '.')) {
$fullName = explode('.', $fieldName);
$model = $fullName[0];
$fieldNameShort = end($fullName);
}
$defaults = array('placeholder' => Inflector::humanize($fieldNameShort));
$options = Set::merge($defaults, $options);
return parent::input($fieldName, $options);
}
示例15: input
public function input($fieldName, $options = array())
{
if (isset($options['label']) && is_string($options['label'])) {
$option['text'] = $options['label'];
$options['label'] = array_merge($option, $this->_inputDefaults['label']);
} else {
if (isset($options['label']['text']) && !isset($options['label']['class'])) {
$options['label'] = array_merge($options['label'], $this->_inputDefaults['label']);
}
}
return parent::input($fieldName, $options);
}