Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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 '';
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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);
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
 /**
  * {@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);
 }
 /**
  * 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);
 }
 /**
  * @param Field $field
  * @return string
  */
 public function labelField(Field $field)
 {
     return $this->builder->label($field->name, $field->value, $field->getAttributes());
 }
Esempio n. 10
0
 /**
  * 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);
 }
Esempio n. 11
0
 /**
  * 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));
 }
Esempio n. 12
0
 /**
  * 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;
 }