当前位置: 首页>>代码示例>>PHP>>正文


PHP FormHelper::label方法代码示例

本文整理汇总了PHP中FormHelper::label方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::label方法的具体用法?PHP FormHelper::label怎么用?PHP FormHelper::label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormHelper的用法示例。


在下文中一共展示了FormHelper::label方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file

 /**
  * ファイルインプットボックス出力
  * 画像の場合は画像タグ、その他の場合はファイルへのリンク
  * そして削除用のチェックボックスを表示する
  * [カスタムオプション]
  * imgsize・・・画像のサイズを指定する
  * 
  * @param string $fieldName
  * @param array $options
  * @return string
  * @access public
  */
 function file($fieldName, $options = array())
 {
     $linkOptions = $_options = array('imgsize' => 'midium', 'rel' => '', 'title' => '');
     $options = $this->_initInputField($fieldName, Set::merge($_options, $options));
     $linkOptions['imgsize'] = $options['imgsize'];
     $linkOptions['rel'] = $options['rel'];
     $linkOptions['title'] = $options['title'];
     unset($options['imgsize']);
     unset($options['rel']);
     unset($options['title']);
     $view =& ClassRegistry::getObject('view');
     $_field = $view->entity();
     $modelName = $_field[0];
     $field = $_field[1];
     if (ClassRegistry::isKeySet($modelName)) {
         $model =& ClassRegistry::getObject($modelName);
     } else {
         return;
     }
     $fileLinkTag = $this->fileLink($fieldName, $linkOptions);
     $fileTag = parent::file($fieldName, $options);
     $delCheckTag = parent::checkbox($modelName . '.' . $field . '_delete') . parent::label($modelName . '.' . $field . '_delete', '削除する');
     $hiddenValue = $this->value($fieldName . '_');
     $fileValue = $this->value($fieldName);
     if (is_array($fileValue) && empty($fileValue['tmp_name']) && $hiddenValue) {
         $hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $hiddenValue));
     } else {
         $hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $this->value($fieldName)));
     }
     $out = $fileTag;
     if ($fileLinkTag) {
         $out .= '&nbsp;' . $delCheckTag . $hiddenTag . '<br />' . $fileLinkTag;
     }
     return '<div class="upload-file">' . $out . '</div>';
 }
开发者ID:nojimage,项目名称:basercms,代码行数:47,代码来源:upload.php

示例2: label

 /**
  * Returns a formatted LABEL element for HTML FORMs. Will automatically generate
  * a `for` attribute if one is not provided.
  *
  * @param string       $fieldName This should be "Modelname.fieldname"
  * @param string       $text      Text that will appear in the label field. If
  *                                $text is left undefined the text will be inflected from the
  *                                fieldName.
  * @param array|string $options   An array of HTML attributes, or a string, to be used as a class name.
  * @return string The formatted label element
  */
 public function label($fieldName = null, $text = null, $options = [])
 {
     if (empty($options)) {
         $options = 'control-label';
     }
     return parent::label($fieldName, $text, $options);
 }
开发者ID:cakeoven,项目名称:CakeTwitterBootstrap,代码行数:18,代码来源:BootstrapFormHelper.php

示例3: label

 /**
  * Cleans up labels text in admin interface
  * @param null $fieldName
  * @param null $text
  * @param array $options
  * @return string
  */
 public function label($fieldName = null, $text = null, $options = array())
 {
     if (!empty($this->request->params['admin'])) {
         if ($text === null) {
             if (strpos($fieldName, '.') !== false) {
                 $fieldElements = explode('.', $fieldName);
                 $text = array_pop($fieldElements);
             } else {
                 $text = $fieldName;
             }
             if (substr($text, -3) == '_id') {
                 $text = substr($text, 0, -3);
             }
             $text = __d('admin', Inflector::humanize(Inflector::underscore($text)));
         }
         $response = parent::label($fieldName, $text, $options);
     }
     return parent::label($fieldName, $text, $options);
 }
开发者ID:mathg,项目名称:skinsound,代码行数:26,代码来源:MyFormHelper.php

示例4: _constructLabel

 /**
  * _construct_label
  *
  * @param mixed $options
  * @access public
  * @return void
  */
 public function _constructLabel($options, $basic = true)
 {
     if ($options["label"] === false) {
         return "";
     }
     if (in_array($options["type"], array("checkbox"))) {
         $opt = $options;
         $opt["type"] = "";
         $input = $this->_constructInput($opt);
         $options["label"] = parent::label($options["field"], $input . $options["label"], "checkbox");
     } else {
         $class = !$basic ? "control-label" : null;
         if (!empty($options["label"])) {
             $options["label"] = parent::label($options["field"], $options["label"], array("class" => $class));
         } else {
             $options["label"] = parent::label($options["field"], null, array("class" => $class));
         }
     }
     return $options["label"];
 }
开发者ID:Asdafers,项目名称:MyAL,代码行数:27,代码来源:BootstrapHelper.php

示例5: datePicker

    public function datePicker($fieldName, $attributes = array())
    {
        $text = $fieldName;
        if (isset($attributes['label'])) {
            $text = $attributes['label'];
        }
        $label = parent::label($text, null, array('class' => 'col-lg-2 control-label'));
        $id = $this->domId($fieldName);
        $inputId = $id . '_Input';
        $name = $this->_name(null, $fieldName);
        $name = $name['name'];
        $currentTime = '';
        if (isset($attributes['value'])) {
            $currentTime = $attributes['value'];
        }
        $html = <<<EOD
<div class="form-group">
\t{$label}
\t<div class="col-lg-10">\t\t\t\t
\t\t<div class='input-group date datepicker' id="{$id}">
\t\t<input type='text' class="form-control" value="{$currentTime}" />
\t\t<span class="input-group-addon">
\t\t<span class="glyphicon glyphicon-calendar"></span>
\t\t</span>
\t\t\t\t
\t\t<input type="hidden" name="{$name}[month]" id="{$id}Month" value="" />
\t\t<input type="hidden" name="{$name}[day]" id="{$id}Day" value="" />
\t\t<input type="hidden" name="{$name}[year]" id="{$id}Year" value="" />
\t\t<input type="hidden" name="{$name}[hour]" id="{$id}Hour" value="" />
\t\t<input type="hidden" name="{$name}[min]" id="{$id}Min" value="" />
\t\t<input type="hidden" name="{$name}[meridian]" id="{$id}Meridian" value="" />\t\t
\t\t\t\t\t
\t\t</div>
\t</div>\t\t\t\t
</div>\t\t
EOD;
        return $html;
    }
开发者ID:KamiMoon,项目名称:volunteeromaha,代码行数:38,代码来源:Bootstrap3FormHelper.php

示例6: label

 /**
  * Returns a formatted LABEL element for HTML FORMs.
  *
  * Overriden to refer to field_names.po unless the label is explicitly passed
  *
  * @param string $fieldName This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated
  * @param string $text Text that will appear in the label field.
  * @return string The formatted LABEL element
  */
 public function label($fieldName = null, $text = null, $attributes = array())
 {
     if (empty($fieldName)) {
         $view = ClassRegistry::getObject('view');
         $fieldName = implode('.', $view->entity());
     }
     if ($text === null) {
         if (strpos($fieldName, '.')) {
             $alias = explode('.', $fieldName);
             if (count($alias) == 3) {
                 $text = str_replace($alias[1] . '.', '', $fieldName);
             } else {
                 $text = $fieldName;
             }
             $alias = $alias[0];
             $text = str_replace('.', ' ', $fieldName);
         } else {
             $view = ClassRegistry::getObject('view');
             $alias = $view->association ? $view->association : $view->model;
             $text = $alias . ' ' . $fieldName;
         }
         if (substr($text, -3) == '_id') {
             $text = substr($text, 0, strlen($text) - 3);
         }
         $_text = Inflector::humanize(Inflector::underscore($text));
         $pluginDomain = '';
         if (!empty($this->params['plugin'])) {
             $models = MiCache::mi('models', $this->params['plugin']);
             if (in_array($alias, $models)) {
                 $pluginDomain = Inflector::underscore($this->params['plugin']) . '_';
             }
         }
         $text = __d($pluginDomain . 'field_names', $_text, true);
         if ($_text === $text) {
             $text = str_replace(Inflector::humanize(Inflector::underscore($alias)) . ' ', '', $_text);
         }
     }
     return parent::label($fieldName, $text, $attributes);
 }
开发者ID:hiromi2424,项目名称:mi,代码行数:48,代码来源:mi_form.php

示例7: label

 public function label($fieldName = null, $text = null, $options = array())
 {
     $options = $this->addClass($options, 'control-label');
     return parent::label($fieldName, $text, $options);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:5,代码来源:BootstrapFormHelper.php

示例8: checkbox

 /**
  * Creates a checkbox input widget.
  * MODIFIED 2008/10/24 egashira
  *          hiddenタグを出力しないオプションを追加
  *
  * @param string $fieldNamem Name of a field, like this "Modelname.fieldname"
  * @param array $options Array of HTML attributes.
  *		'value' - the value of the checkbox
  *		'checked' - boolean indicate that this checkbox is checked.
  * @todo Right now, automatically setting the 'checked' value is dependent on whether or not the
  * 		 checkbox is bound to a model.  This should probably be re-evaluated in future versions.
  * @return string An HTML text input element
  * @access public
  */
 function checkbox($fieldName, $options = array())
 {
     // CUSTOMIZE ADD 2011/05/07 ryuring
     // >>> hiddenをデフォルトオプションに追加
     $options = array_merge(array('hidden' => true), $options);
     $hidden = $options['hidden'];
     unset($options['hidden']);
     // <<<
     $options = $this->_initInputField($fieldName, $options);
     $value = current($this->value());
     if (!isset($options['value']) || empty($options['value'])) {
         $options['value'] = 1;
     } elseif (!isset($options['checked']) && !empty($value) && $value === $options['value'] || !empty($options['checked'])) {
         $options['checked'] = 'checked';
     }
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> hiddenオプションがある場合のみ、hiddenタグを出力
     /*$hiddenOptions = array(
     			'id' => $options['id'] . '_', 'name' => $options['name'],
     			'value' => '0', 'secure' => false
     		);
     		if (isset($options['disabled']) && $options['disabled'] == true) {
     			$hiddenOptions['disabled'] = 'disabled';
     		}
     		$output = $this->hidden($fieldName, $hiddenOptions);*/
     // ---
     if ($hidden) {
         $hiddenOptions = array('id' => $options['id'] . '_', 'name' => $options['name'], 'value' => '0', 'secure' => false);
         if (isset($options['disabled']) && $options['disabled'] == true) {
             $hiddenOptions['disabled'] = 'disabled';
         }
         $output = $this->hidden($fieldName, $hiddenOptions);
     } else {
         $output = '';
     }
     // <<<
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> label を追加
     /*return $this->output($output . sprintf(
     			$this->Html->tags['checkbox'],
     			$options['name'],
     			$this->_parseAttributes($options, array('name'), null, ' ')
     		));*/
     // ---
     if (!empty($options['label'])) {
         $label = '&nbsp;' . parent::label($fieldName, $options['label']);
     } else {
         $label = '';
     }
     return $this->output($output . sprintf($this->Html->tags['checkbox'], $options['name'], $this->_parseAttributes($options, array('name'), null, ' '))) . $label;
     // <<<
 }
开发者ID:ryuring,项目名称:basercms,代码行数:66,代码来源:bc_form.php

示例9: checkbox

 /**
  * Creates a checkbox input widget.
  * MODIFIED 2008/10/24 egashira
  *          hiddenタグを出力しないオプションを追加
  *
  * ### Options:
  *
  * - `value` - the value of the checkbox
  * - `checked` - boolean indicate that this checkbox is checked.
  * - `hiddenField` - boolean to indicate if you want the results of checkbox() to include
  *    a hidden input with a value of ''.
  * - `disabled` - create a disabled input.
  * - `default` - Set the default value for the checkbox. This allows you to start checkboxes
  *    as checked, without having to check the POST data. A matching POST data value, will overwrite
  *    the default value.
  *
  * @param string $fieldName Name of a field, like this "Modelname.fieldname"
  * @param array $options Array of HTML attributes.
  * @return string An HTML text input element.
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
  */
 public function checkbox($fieldName, $options = array())
 {
     // CUSTOMIZE ADD 2011/05/07 ryuring
     // >>> hiddenをデフォルトオプションに追加
     $options = array_merge(array('hidden' => true), $options);
     $hidden = $options['hidden'];
     unset($options['hidden']);
     // <<<
     $valueOptions = array();
     if (isset($options['default'])) {
         $valueOptions['default'] = $options['default'];
         unset($options['default']);
     }
     $options += array('value' => 1, 'required' => false);
     $options = $this->_initInputField($fieldName, $options) + array('hiddenField' => true);
     $value = current($this->value($valueOptions));
     $output = '';
     if (!isset($options['checked']) && !empty($value) && $value == $options['value'] || !empty($options['checked'])) {
         $options['checked'] = 'checked';
     }
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> hiddenオプションがある場合のみ、hiddenタグを出力
     // 2014/03/23 ryuring CakePHP側が実装していたが互換性の為に残す
     //if ($options['hiddenField']) {
     // ---
     if ($hidden !== false && $options['hiddenField'] !== false) {
         // <<<
         $hiddenOptions = array('id' => $options['id'] . '_', 'name' => $options['name'], 'value' => $options['hiddenField'] !== true ? $options['hiddenField'] : '0', 'form' => isset($options['form']) ? $options['form'] : null, 'secure' => false);
         if (isset($options['disabled']) && $options['disabled']) {
             $hiddenOptions['disabled'] = 'disabled';
         }
         $output = $this->hidden($fieldName, $hiddenOptions);
     }
     unset($options['hiddenField']);
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // label を追加
     // CUSTOMIZE MODIRY 2014/10/27 ryuring
     // チェックボックスをラベルで囲う仕様に変更
     // >>>
     //return $output . $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null)));
     // ---
     if (!empty($options['label'])) {
         return $output . parent::label($fieldName, $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null))) . $options['label']);
     } else {
         return $output . $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null)));
     }
     // <<<
 }
开发者ID:baserproject,项目名称:basercms,代码行数:69,代码来源:BcFormHelper.php

示例10: label

 /**
  *
  * Create & return a label message (Twitter Boostrap like).
  *
  **/
 public function label($fieldName = null, $text = null, $options = array())
 {
     if ($this->currentInputType == 'checkbox') {
         //  || $this->currentInputType == 'radio') {
         return $text;
     }
     if (!$this->inline) {
         $options = $this->addClass($options, 'control-label');
     }
     if ($this->horizontal) {
         $options = $this->addClass($options, $this->_getColClass('label'));
     }
     if ($this->inline) {
         $options = $this->addClass($options, 'sr-only');
     }
     return parent::label($fieldName, $text, $options);
 }
开发者ID:tsmsogn,项目名称:cakephp-bootstrap3-helpers,代码行数:22,代码来源:BootstrapFormHelper.php

示例11: _clearfix

 protected function _clearfix($name, $input, $options)
 {
     $default = array('label' => null, 'type' => null, 'div' => array('class' => 'controls'));
     $options = Set::merge($default, $options);
     $out = array();
     if ($options['label'] !== false) {
         $text = $options['label']['text'];
         if ($options['type'] === 'checkbox') {
             unset($options['label']['text']);
             $options['label']['for'] = '';
         }
         $out[] = parent::label(FALSE, $text, $options['label']);
     }
     $out[] = $this->Html->div($options['div']['class'], $input, $options['div']);
     $clearfix = 'control-group';
     if (parent::error($name)) {
         $clearfix .= ' error';
     }
     return $this->Html->div($clearfix, implode("\n", $out));
 }
开发者ID:nano-eight,项目名称:TwitterBootstrap,代码行数:20,代码来源:BootstrapFormHelper.php

示例12: label

 /**
  *
  * Create & return a label message (Twitter Boostrap like).
  *
  **/
 public function label($fieldName = null, $text = null, $options = array())
 {
     if ($this->currentInputType == 'checkbox') {
         if ($text === null) {
             if (strpos($fieldName, '.') !== false) {
                 $fieldElements = explode('.', $fieldName);
                 $text = array_pop($fieldElements);
             } else {
                 $text = $fieldName;
             }
             if (substr($text, -3) === '_id') {
                 $text = substr($text, 0, -3);
             }
             $text = __(Inflector::humanize(Inflector::underscore($text)));
         }
         return $text;
     }
     if (!$this->inline) {
         $options = $this->addClass($options, 'control-label');
     }
     if ($this->horizontal) {
         $options = $this->addClass($options, $this->_getColClass('label'));
     }
     if ($this->inline) {
         $options = $this->addClass($options, 'sr-only');
     }
     return parent::label($fieldName, $text, $options);
 }
开发者ID:holt59,项目名称:cakephp-bootstrap3-helpers,代码行数:33,代码来源:BootstrapFormHelper.php

示例13: label

 /**
  * Create & return a label message (Twitter Boostrap like).
  *
  * @param string Field name.
  * @param string $text Label name string.
  * @param array $options Array of options for the label.
  * @return string HTML string of the label.
  */
 public function label($fieldName = null, $text = null, $options = [])
 {
     $this->setEntity($fieldName);
     $optField = $this->_magicOptions([]);
     if ($this->formType === GA_HORIZONTAL && $optField['type'] !== 'checkbox') {
         $options = $this->addClass($options, GA_CONTROL_LABEL);
     }
     return parent::label($fieldName, $text, $options);
 }
开发者ID:gezeresolutionsweb,项目名称:cakeganache,代码行数:17,代码来源:GanacheFormHelper.php

示例14: confirm

 function confirm($fieldName, $options = array(), $group = array())
 {
     $defaults = array('type' => null, 'appBefore' => null, 'appAfter' => null, 'appPath' => null, 'appPathOption' => null, 'appPathAfter' => null, 'appImg' => null);
     $options = array_merge($defaults, $options);
     //グループ設定
     $createTr = true;
     $closeTr = true;
     $this->displayed[] = $fieldName;
     //一列に複数フォーム表示する場合に
     //tr,tdのタグを使用するフラグを取得する
     if (!empty($group)) {
         $tr = $this->__getTrFlag($group);
         extract($tr);
     }
     $label = null;
     if (!empty($options['label'])) {
         $label = $options['label'];
     }
     $options['label'] = false;
     $view =& ClassRegistry::getObject('view');
     $this->setEntity($fieldName);
     $model =& ClassRegistry::getObject($this->model());
     $type = $model->getColumnType($this->field());
     if ($type == 'datetime') {
         $options = $this->setDatetimeOptions($options);
     }
     $before = $options['appBefore'];
     $after = $options['appAfter'];
     $path = $options['appPath'];
     $pathOption = $options['appPathOption'];
     $pathAfter = $options['appPathAfter'];
     $img = $options['appImg'];
     unset($options['appBefore'], $options['appAfter'], $options['appPath'], $options['appPathOption'], $options['appPathAfter'], $options['appImg']);
     //値を設定
     list($modelName, $field) = $view->entity();
     $value = $this->data[$modelName][$field];
     switch ($options['type']) {
         case 'select':
         case 'radio':
         case 'checkbox':
             $value = $options['options'][$value];
             break;
         case 'textarea':
             $value = nl2br($value);
             break;
         case 'file':
             if (empty($path)) {
                 break;
             }
             if ($img === true) {
                 $value = $this->Html->div('input checkbox required', $this->Html->image($path, !empty($pathOption) ? $pathOption : array()));
             } else {
                 $value = $this->Html->div('input checkbox required', $this->Html->link(__d('tools', 'Display file', true), $path, !empty($pathOption) ? $pathOption : array()));
             }
             break;
         default:
             break;
     }
     $tr_class = array();
     if (in_array($this->field(), $this->fieldset['validates'])) {
         $tr_class[] = 'required';
     }
     $out = '';
     if ($createTr) {
         $out .= "<tr" . (!empty($tr_class) ? ' class="' . implode(' ', $tr_class) . '"' : '') . ">\n";
         $out .= "<th class='vtop'>\n";
         $out .= parent::label($fieldName, $label);
         $out .= "</th>\n";
         $out .= "<td class='vtop'>\n";
     }
     $out .= $before . $value . $after;
     if ($closeTr) {
         $out .= "</td>\n";
         $out .= "</tr>\n";
     }
     return $out;
 }
开发者ID:masayukiando,项目名称:googlemap-search_ActionScript3.0,代码行数:77,代码来源:app_form.php


注:本文中的FormHelper::label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。