Former\Form\Group::setLabel PHP Method

setLabel() public method

Adds a label to the group
public setLabel ( string $label )
$label string A label
    public function setLabel($label)
    {
        if (!$label instanceof Element) {
            $label = Helpers::translate($label);
            $label = Element::create('label', $label)->for($label);
        }
        $this->label = $label;
    }

Usage Example

Beispiel #1
0
 /**
  * Adds a label to the group/field
  *
  * @param  string $text       A label
  * @param  array  $attributes The label's attributes
  *
  * @return Field              A field
  */
 public function label($text, $attributes = array())
 {
     // Create the Label element
     $for = $this->id ?: $this->name;
     $label = $this->app['former']->label($text, $for, $attributes);
     // Set label
     $this->label = $label;
     if ($this->group) {
         $this->group->setLabel($label);
     }
     return $this;
 }