當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormBuilder::label方法代碼示例

本文整理匯總了PHP中Illuminate\Html\FormBuilder::label方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormBuilder::label方法的具體用法?PHP FormBuilder::label怎麽用?PHP FormBuilder::label使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Html\FormBuilder的用法示例。


在下文中一共展示了FormBuilder::label方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: label

 /**
  * Create a form label element.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 public function label($name, $value = null, $options = array())
 {
     if ($this->validationErrors && $this->validationErrors->has($name)) {
         $options = $this->addClass($options, $this->errorCssClass);
     }
     return parent::label($name, $value, $options);
 }
開發者ID:wingsline,項目名稱:inuitcss,代碼行數:15,代碼來源:FormBuilder.php

示例2: label

 /**
  * Create a form label field.
  *
  * @param string $name
  * @param string $label
  * @param array  $options
  *
  * @return string
  */
 protected function label($name, $label = null, array $options = array())
 {
     $options = array_merge(array('class' => 'control-label ' . $this->labelClass), $options);
     if ($label) {
         return $this->form->label($name, $label, $options) . "\n";
     }
     return '';
 }
開發者ID:illuminate3,項目名稱:bootawesome,代碼行數:17,代碼來源:BootstrapBase.php

示例3: getLabelFor

 /**
  * Get the label for a field
  *
  * @param  InputInterface $field
  * @param  string         $id
  * @param  array          $attributes
  *
  * @return string|boolean
  */
 public function getLabelFor(InputInterface $field, $id, array $attributes = array())
 {
     $label = $field->getLabel();
     if ($label) {
         return $this->builder->label($id, $label, $attributes);
     }
     return false;
 }
開發者ID:ruysu,項目名稱:laravel4-form,代碼行數:17,代碼來源:FieldCollection.php

示例4: label

 /**
  * Create a form label element.
  *
  * @param string $name
  * @param string $value
  * @param array $options
  * @return string 
  * @static 
  */
 public static function label($name, $value = null, $options = array())
 {
     return \Illuminate\Html\FormBuilder::label($name, $value, $options);
 }
開發者ID:nmkr,項目名稱:basic-starter,代碼行數:13,代碼來源:_ide_helper.php

示例5: buildLabel

 /**
  * Builds the label html
  *
  * @param  string  $name The name of the html field
  * @param  string  $label The label name
  * @param  array   $attributes
  * @return string
  */
 private function buildLabel($name, $label = '', $attributes = array())
 {
     $out = '';
     if (!empty($label)) {
         if (!empty($attributes['class'])) {
             $attributes['class'] .= ' control-label';
         } else {
             $attributes['class'] = 'control-label';
         }
         if ($this->getOption('requiredLabel') and substr($label, -strlen($this->getOption('requiredLabel'))) == $this->getOption('requiredLabel')) {
             $label = $this->getOption('requiredPrefix') . str_replace($this->getOption('requiredLabel'), '', $label) . $this->getOption('requiredSuffix');
             $attributes['class'] .= ' ' . $this->getOption('requiredClass');
         }
         $name = $this->getOption('idPrefix') . $name;
         $out .= parent::label($name, $label, $attributes);
     }
     return $out;
 }
開發者ID:jarnstedt,項目名稱:former,代碼行數:26,代碼來源:Former.php

示例6: label

 /**
  * Create a label.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $options
  *
  * @return string
  */
 public function label($name, $value = null, $options = [])
 {
     $this->addErrorClass($name, $options);
     return parent::label($name, $value, $options);
 }
開發者ID:stolz,項目名稱:laravel-form-builder,代碼行數:14,代碼來源:Foundation.php

示例7: label

 /**
  * {@inheritdoc}
  * @param string      $name    The name of the object this label will be
  *                             attached to
  * @param string|null $value   The text of the label
  * @param array       $options The options of the label
  * @return string
  */
 public function label($name, $value = null, $options = array())
 {
     $options['class'] = isset($options['class']) ? self::LABEL . ' ' . $options['class'] : self::LABEL;
     return parent::label($name, $value, $options);
 }
開發者ID:olax,項目名稱:epetitions,代碼行數:13,代碼來源:Form.php

示例8: label

 /**
  * Create a Bootstrap label.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 public function label($name, $value = null, $options = array())
 {
     $options = $this->getLabelOptions($options);
     return $this->form->label($name, $value, $options);
 }
開發者ID:Javier-Rotelli,項目名稱:bootstrap-form,代碼行數:13,代碼來源:BootstrapForm.php

示例9: labelField

 /**
  * @param Field $field
  * @return string
  */
 public function labelField(Field $field)
 {
     return $this->builder->label($field->name, $field->value, $field->getAttributes());
 }
開發者ID:iyoworks,項目名稱:form-builder,代碼行數:8,代碼來源:LaravelFormRenderer.php

示例10: label

 /**
  * Create a Bootstrap label.
  *
  * @param  string $name
  * @param  string $value
  * @param  array $options
  * @return string
  */
 public function label($name, $value = null, $options = [])
 {
     $options = $this->getLabelOptions($options);
     return $this->form->label($name, \Lang::get($value), $options);
 }
開發者ID:Junyue,項目名稱:zidisha2,代碼行數:13,代碼來源:BootstrapFormBuilder.php

示例11: label

 /**
  * Create a form label element.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $options
  * @return \Illuminate\Support\HtmlString
  */
 public function label($name, $value = null, $options = [])
 {
     return new HtmlString(parent::label($name, $value, $options));
 }
開發者ID:minors,項目名稱:html,代碼行數:12,代碼來源:FormBuilder.php

示例12: select

 /**
  * Create a select box field.
  *
  * @param  string  $name
  * @param  array   $list
  * @param  string  $selected
  * @param  array   $options
  * @return string
  */
 public function select($name, $list = array(), $selected = null, $options = array())
 {
     $selected = $this->getValueAttribute($name, $selected);
     $options['id'] = $this->getIdAttribute($name, $options);
     if (!isset($options['name'])) {
         $options['name'] = $name;
     }
     // The form-control class should be a default class for every input
     // generated. The class option on the input also overrides every
     // default classes set.
     if (isset($options['class'])) {
         $this->setClass($options['class']);
     }
     $options['class'] = "form-control " . $this->class;
     // Removes keys for the wrapper from the $options array and puts them
     // into variables to prevent them from appearing as attributes on the
     // input itself.
     array_key_exists('label', $options) ? $label = array_pull($options, 'label') : ($label = null);
     $html = array();
     foreach ($list as $value => $display) {
         $html[] = $this->getSelectOption($display, $value, $selected);
     }
     // Once we have all of this HTML, we can join this into a single element after
     // formatting the attributes into an HTML "attributes" string, then we will
     // build out a final select statement, which will contain all the values.
     $options = $this->html->attributes($options);
     $list = implode('', $html);
     // Sets the $input variable to the newly generated input field, this
     // variable will then be used within the Bootstrap wrapper instead of
     // being returned directly.
     $input = "<select{$options}>{$list}</select>";
     // If there are errors we want to add the has-error class to the form-group
     // tag to make the border glow red.
     if (!is_null($this->errors) && $this->errors->has($name) && $name != NULL) {
         $this->formGroupClass .= " has-error";
         // If exteded feedback is also enabled we will also add the has-feedback
         // class to allow showing the icons.
         if ($this->feedback === true) {
             $this->formGroupClass .= " has-feedback";
         }
     }
     // The return variable holds the HTML output that is returned to the user.
     // It's purposely divided into lines to allow for better reading and
     // easier conditionals for some of the output.
     $return = '<div class="form-group ' . $this->formGroupClass . '">';
     $return .= '<div class="row">';
     $return .= '<div class="col-md-4">';
     // If a label is given then we show the label here. Notice
     // that the form class is available as IlluminateFormBuilder
     // and not as Form.
     if (!is_null($label)) {
         $return .= IlluminateFormBuilder::label($name, $label);
     }
     $return .= '</div>';
     $return .= '<div class="col-md-8 text-right">';
     // If errors are present we show the error message here.
     // Error styling can be done using the validation-error
     // class that is added automatically.
     if (!is_null($this->errors) && $this->errors->has($name) && $name != NULL) {
         $return .= $this->errors->first($name, '<p class="text-danger validation-error">:message</p>');
     }
     $return .= '</div>';
     $return .= '</div>';
     $return .= $input;
     $return .= '</div>';
     $this->resetConfig();
     return $return;
 }
開發者ID:YammYcoding,項目名稱:BootstrapForm,代碼行數:77,代碼來源:BootstrapForm.php


注:本文中的Illuminate\Html\FormBuilder::label方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。