Exemplo n.º 1
0
 /**
  * Add a class to the current field
  *
  * @param string $class The class to add
  */
 public function addClass($class)
 {
     if (is_array($class)) {
         $class = implode(' ', $class);
     }
     $this->attributes = \Former\Helpers::addClass($this->attributes, $class);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Opens a control group
  *
  * @return string Opening tag
  */
 private function open()
 {
     // If any errors, set state to errors
     $errors = Former::getErrors();
     if ($errors) {
         $this->state('error');
     }
     // Retrieve state and append it to classes
     if ($this->state) {
         $this->attributes = Helpers::addClass($this->attributes, $this->state);
     }
     // Required state
     if (Former::field()->isRequired()) {
         $this->attributes = Helpers::addClass($this->attributes, Config::get('required_class'));
     }
     return '<div' . HTML::attributes($this->attributes) . '>';
 }
Exemplo n.º 3
0
 /**
  * Add the correct classes to a group
  *
  * @param  array $attributes The group's attributes
  * @return array             The modified attributes
  */
 public static function getGroupClasses($attributes)
 {
     if (static::is('bootstrap')) {
         $attributes = Helpers::addClass($attributes, 'control-group');
     }
     return $attributes;
 }
Exemplo n.º 4
0
 /**
  * Prints out the current tag
  *
  * @return string An uneditable input tag
  */
 public function __toString()
 {
     $this->attributes = Helpers::addClass($this->atteibutes, 'uneditable-input');
     return '<span' . HTML::attributes($attributes) . '>' . HTML::entities($value) . '</span>';
 }
Exemplo n.º 5
0
 /**
  * Render a text element as a search element
  */
 private function asSearch()
 {
     $this->type = 'text';
     $this->attributes = Helpers::addClass($this->attributes, 'search-query');
 }
Exemplo n.º 6
0
 /**
  * Add a class to the current field
  *
  * @param string $class The class to add
  */
 public function addClass($class)
 {
     $this->attributes = Helpers::addClass($this->attributes, $class);
 }
Exemplo n.º 7
0
 /**
  * Prints out the current label
  *
  * @param  string $name A field to link the label to
  * @return string       A <label> tag
  */
 private function getLabel($name)
 {
     if (!$this->label) {
         return false;
     }
     extract($this->label);
     $attributes = Helpers::addClass($attributes, 'control-label');
     return \Form::label($name, $label, $attributes);
 }