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


PHP Form::label方法代码示例

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


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

示例1: displayForm

 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $class = get_called_class();
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge form-control');
     if (!isset($input_attributes['id'])) {
         $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName'];
     }
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
     $label_text = $settings['title'] . ($required ? ' *' : '');
     // Build the input
     $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />';
     // Build the label
     $label = !$include_label ? '' : \Form::label($label_text . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     // Wrap it in an input group
     $input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), ' '));
     // Don't wrap the input if wrap is set to false
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:27,代码来源:Color.php

示例2: displayForm

 /** @inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     // No point in ever showing this field if lang isn't enabled
     if (!\CMF::$lang_enabled) {
         return '';
     }
     \Lang::load('languages', true, 'en', true, true);
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     if ($settings['active_only']) {
         $options = array_map(function ($lang) {
             return \Arr::get(\Lang::$lines, 'en.languages.' . $lang['code'], \Lang::get('admin.errors.language.name_not_found'));
         }, \CMF\Model\Language::select('item.code', 'item', 'item.code')->orderBy('item.pos', 'ASC')->where('item.visible = true')->getQuery()->getArrayResult());
     } else {
         $options = \Arr::get(\Lang::$lines, 'en.languages', array());
     }
     // Whether to allow an empty option
     if (isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !$required && $settings['allow_empty']) {
         $options = array('' => '') + $options;
     }
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $input = \Form::select($settings['mapping']['fieldName'], $value, $options, $input_attributes);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', array('class' => 'controls control-group' . ($has_errors ? ' error' : '')), $label . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:32,代码来源:Language.php

示例3: displayForm

 public static function displayForm($value, &$settings, $model)
 {
     $settings = static::settings($settings);
     if (!is_array($value)) {
         $value = array();
     }
     // Search input or
     $searchInput = \Form::input($settings['mapping']['fieldName'] . '[search]', null, array('class' => 'input input-xxlarge search-input', 'placeholder' => \Lang::get('admin.common.map_search_placeholder')));
     $searchButton = \Form::button('mapsearch', \Lang::get('admin.verbs.search'), array('class' => 'btn btn-primary'));
     $searchInput = html_tag('div', array('class' => 'form form-inline search-form'), $searchInput . $searchButton);
     // Hidden inputs
     $latInput = \Form::hidden($settings['mapping']['fieldName'] . '[lat]', \Arr::get($value, 'lat'), array('class' => 'lat'));
     $lngInput = \Form::hidden($settings['mapping']['fieldName'] . '[lng]', \Arr::get($value, 'lng'), array('class' => 'lng'));
     $zoomInput = \Form::hidden($settings['mapping']['fieldName'] . '[zoom]', \Arr::get($value, 'zoom'), array('class' => 'zoom'));
     // Other elements
     $required = isset($settings['required']) ? $settings['required'] : false;
     $label_text = $settings['title'] . ($required ? ' *' : '');
     $label = \Form::label($label_text);
     $mapDiv = html_tag('div', array('class' => 'map', 'id' => \Inflector::friendly_title($settings['mapping']['fieldName'], '-', true) . '-bing-map'), ' ');
     // Check that we have an API key
     if (empty($settings['api_key'])) {
         $content = $label . '<div class="well"><p>' . \Lang::get('admin.bing.api_key_not_set') . '</p></div>';
     } else {
         $content = $label . $searchInput . $latInput . $lngInput . $zoomInput . $mapDiv;
     }
     $content = html_tag('div', array('class' => 'controls control-group field-type-bing-map', 'data-field-name' => $settings['mapping']['fieldName']), $content);
     return array('content' => $content, 'js_data' => $settings);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:28,代码来源:BingMap.php

示例4: input

function input($name, $display = null)
{
    if ($display == null) {
        $display = ucfirst($name);
    }
    $data = array('name' => "cliente[{$name}]");
    return Form::text($name, null, $data) . Form::label($name, $display) . '<br>';
}
开发者ID:tusotec,项目名称:Artecol,代码行数:8,代码来源:form.blade.php

示例5: formComponent

 /**
  * Form Component
  */
 public static function formComponent()
 {
     $_templates = Themes::getTemplates();
     foreach ($_templates as $template) {
         $templates[basename($template, '.template.php')] = basename($template, '.template.php');
     }
     echo '<div class="col-xs-3">' . Form::open() . Form::hidden('csrf', Security::token()) . Form::label('sandbox_form_template', __('Sandbox template', 'sandbox')) . Form::select('sandbox_form_template', $templates, Option::get('sandbox_template'), array('class' => 'form-control')) . Html::br() . Form::submit('sandbox_component_save', __('Save', 'sandbox'), array('class' => 'btn btn-default')) . Form::close() . '</div>';
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:11,代码来源:sandbox.admin.php

示例6: testLabelRequired

 /**
  * @covers Form::label
  * @covers Form::removeEndColon
  * @covers Form::addFieldError
  */
 public function testLabelRequired()
 {
     $this->myForm = new \Form();
     $this->myForm->addConstraint('login', \ConstraintFactory::REQUIRED);
     $this->myForm->addFieldError("login", "Wrong login");
     $elt = $this->myForm->label('login', 'my label');
     $this->assertInstanceOf('HtmlElement', $elt);
     $this->assertEquals('<label  class="required error">my label</label>', $elt->__toString());
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:14,代码来源:FormTest.php

示例7: testLabel

 public function testLabel()
 {
     $data = Form::label();
     $this->assertEquals('<label></label>', $data);
     $data = Form::label('Some text');
     $this->assertEquals('<label>Some text</label>', $data);
     $data = Form::label('Some text', ['id' => 'ID', 'class' => 'Class', 'for' => 'for']);
     $this->assertEquals('<label id="ID" class="Class" for="for">Some text</label>', $data);
 }
开发者ID:khaledsaikat,项目名称:html-form,代码行数:9,代码来源:HtmlTest.php

示例8: li_checkbox

 public static function li_checkbox($input, $text, $checked = FALSE, array $attributes = array(), $error = "")
 {
    $atts = array_merge($attributes, array('id'=>$input));
    echo "<li class=\"input_field input_text\">";
    echo Form::label($input, $text);
    echo Form::checkbox($input, NULL, $checked, $atts);
    echo "<span class=\"error\">$error</span>";
    echo "</li>";
 }
开发者ID:nevermlnd,项目名称:cv,代码行数:9,代码来源:form.php

示例9: textAreaGroup

function textAreaGroup($name, $value = NULL, $errors)
{
    $errorClass = $errors->first($name) ? "has-error" : "";
    $output = "<div class='form-group {$errorClass}'>";
    $output .= Form::label($name, ucwords($name));
    $output .= Form::textarea($name, $value, ['class' => 'form-control', 'placeholder' => "Enter {$name}"]);
    $output .= $errors->first($name, '<label>:message</label>');
    return "{$output}</div>";
}
开发者ID:rdok,项目名称:oblivion-pm,代码行数:9,代码来源:helpers.php

示例10: displayForm

 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     // Check stylesSet URL
     $stylesSet = \Arr::get($settings, 'stylesSet');
     if (!empty($stylesSet) && substr($stylesSet, 0, 1) == '/') {
         // Add an absolute URL to the start
         $settings['stylesSet'] = rtrim(\Uri::base(false), '/') . $stylesSet;
     }
     // Add ckeditor to the class for the field
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     $input_attributes['class'] = $input_attributes['class'] . " ckeditor-cmf";
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $input = \Form::textarea($settings['mapping']['fieldName'], strval($value), $input_attributes);
     // Set up required information for any links specified
     if (isset($settings['links']) && is_array($settings['links'])) {
         $links = array();
         foreach ($settings['links'] as $link_type => $link) {
             if (!class_exists($link_type)) {
                 continue;
             }
             $link['table_name'] = \CMF\Admin::getTableForClass($link_type);
             $link['singular'] = $link_type::singular();
             $link['plural'] = $link_type::plural();
             $link['icon'] = $link_type::icon();
             $links[$link_type] = $link;
         }
         $settings['links'] = $links;
     }
     if (isset($settings['stylesSet'])) {
         if (file_exists(DOCROOT . ltrim($settings['stylesSet'], '/'))) {
             $settings['stylesSet'] = 'default:' . \Uri::base(false) . ltrim($settings['stylesSet'], '/');
         } else {
             unset($settings['stylesSet']);
         }
     }
     if (isset($settings['contentsCss'])) {
         if (strpos($settings['contentsCss'], '.php') === false && !file_exists(DOCROOT . ltrim($settings['contentsCss'], '/'))) {
             unset($settings['contentsCss']);
         }
     }
     // Return only the field and label if no wrap is required
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     // Return the widget
     if (isset($settings['widget']) && $settings['widget'] === true) {
         return array('assets' => array(), 'content' => $input, 'widget' => true, 'widget_title' => $settings['title'], 'widget_icon' => 'align-left', 'js_data' => $settings);
     }
     // Return the normal field
     return array('assets' => array(), 'content' => html_tag('div', array('class' => 'control-group ' . ($has_errors ? ' error' : '')), $label . $input), 'widget' => false, 'js_data' => $settings);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:57,代码来源:CKEditor.php

示例11: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $usuario = new User();
     $roles = Role::all()->lists('display_name', 'id');
     $myroles = [];
     $title = 'Agregar usuario';
     $form_data = ['route' => 'usuario.store', 'class' => 'form-horizontal'];
     $password_field = \Form::label('password', 'Contraseña') . \Form::password('password', ['class' => 'form-control']);
     return view('usuario.form')->with(compact('title', 'usuario', 'form_data', 'password_field', 'roles', 'myroles'));
 }
开发者ID:ericray,项目名称:gas,代码行数:15,代码来源:UserController.php

示例12: displayForm

 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $id = isset($value) ? $value->id : '';
     $settings = static::settings($settings);
     $settings['cid'] = 'field_' . md5($settings['mapping']['fieldName'] . static::type());
     $required = isset($settings['required']) ? $settings['required'] : false;
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $target_class = $settings['mapping']['targetEntity'];
     $target_table = \CMF\Admin::getTableForClass($target_class);
     $target_prop = $settings['mapping']['isOwningSide'] === true ? $settings['mapping']['inversedBy'] : $settings['mapping']['mappedBy'];
     if (empty($target_prop) || is_null($model->id)) {
         $target_prop = false;
     }
     $add_link = \Uri::create('/admin/' . $target_table . '/create?_mode=inline&_cid=' . $settings['cid'] . ($target_prop !== false ? '&' . $target_prop . '=' . $model->id : ''));
     $options = $target_class::options(\Arr::get($settings, 'filters', array()), array(), null, null, null, is_array($settings['select2']), \Arr::get($settings, 'group_by'));
     $has_controls = $settings['create'] !== false;
     // Description?
     $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
     if ($settings['allow_empty']) {
         $options = array('' => '') + $options;
     }
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = $settings['input_attributes'];
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $add_link = html_tag('a', array('href' => $add_link, 'class' => 'btn btn-mini btn-create'), '<i class="fa fa-plus"></i> &nbsp;create ' . strtolower($target_class::singular()));
     // Permissions
     $settings['can_edit'] = \CMF\Auth::can('edit', $target_class);
     $settings['can_create'] = \CMF\Auth::can('create', $target_class) && $settings['can_edit'];
     $settings['create'] = $settings['create'] && $settings['can_create'];
     $settings['edit'] = $settings['edit'] && $settings['can_edit'];
     if ($settings['create'] === false) {
         $add_link = " ";
     }
     $controls_top = html_tag('div', array('class' => 'controls-top'), $add_link);
     if (is_array($settings['select2'])) {
         $input_attributes['class'] .= 'input-xxlarge select2';
         $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes);
         $settings['select2']['placeholder'] = 'click to select ' . strtolower($target_class::singular()) . '...';
         $settings['select2']['target_table'] = $target_table;
         // Permissions
         $settings['select2']['create'] = $settings['create'];
         $settings['select2']['edit'] = $settings['edit'];
         if (!$required) {
             $settings['select2']['allowClear'] = true;
         }
         return array('content' => html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('css' => array('/admin/assets/select2/select2.css'), 'js' => array('/admin/assets/select2/select2.min.js', '/admin/assets/js/fields/select2.js')), 'js_data' => $settings['select2']);
     }
     $input_attributes['class'] .= ' input-xxlarge';
     $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>';
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:56,代码来源:ManyToOne.php

示例13: inputs

 public function inputs($attributes = NULL)
 {
     $out = array();
     foreach ($this->_stream as $name => $value) {
         $input = Facebook_Stream::$input_prefix . $name . Facebook_Stream::$input_suffix;
         if ($this->_inputs[$name]['hidden']) {
             $out[] = $this->input($name, $attributes);
         } else {
             $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($input, $this->_inputs[$name]['label'], $attributes), ':description' => $this->_inputs[$name]['description'], ':input' => $this->input($name, $attributes)));
         }
     }
     return implode("\n", $out);
 }
开发者ID:jerfowler,项目名称:kohana-facebook,代码行数:13,代码来源:stream.php

示例14: _media_type

 protected function _media_type($input, $attributes)
 {
     $type = Facebook_Attachment::$input_prefix . 'media-type' . Facebook_Attachment::$input_suffix;
     $src = Facebook_Attachment::$input_prefix . 'media-src' . Facebook_Attachment::$input_suffix;
     $upload = Facebook_Attachment::$input_prefix . 'upload' . Facebook_Attachment::$input_suffix;
     $href = Facebook_Attachment::$input_prefix . 'media-href' . Facebook_Attachment::$input_suffix;
     $out = array();
     $out[] = Form::hidden($type, 'image');
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($src, 'Image Location URL', $attributes), ':description' => 'Each record must contain a src key, which maps to the photo URL', ':input' => Form::input($src, NULL, $attributes)));
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($upload, 'Image Upload', $attributes), ':description' => 'Upload a file to use as the image src', ':input' => Form::file($upload, $attributes)));
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($href, 'Image Hyperlink Destination', $attributes), ':description' => 'Maps to the URL where a user should be taken if he or she clicks the photo.', ':input' => Form::input($href, NULL, $attributes)));
     return implode("\n", $out);
 }
开发者ID:jerfowler,项目名称:kohana-facebook,代码行数:13,代码来源:image.php

示例15: displayForm

 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : ''));
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName']);
     $input = $value instanceof \CMF\Model\Base ? strval($value->display()) : strval($value);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:14,代码来源:ReadOnly.php


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