Ejemplo n.º 1
0
 public function __construct($name, $label = null, $attributes = [])
 {
     if (isset($attributes['options'])) {
         $this->options = $attributes['options'];
         unset($attributes['options']);
     } else {
         $this->options = [];
     }
     parent::__construct($name, $label, $attributes);
 }
Ejemplo n.º 2
0
 public function attr($name, $value = null)
 {
     if ($name == 'checked' && $value !== null) {
         $this->attributes[$name] = $value;
         $this->trigger('valueChanged', ['oldValue' => isset($this->attributes[$name]) ? $this->attributes[$name] : null]);
         return $this;
     } else {
         return parent::attr($name, $value);
     }
 }
Ejemplo n.º 3
0
 /**
  * Add an instance of Element to the form.
  * @param Element $element
  */
 public function addElement(Element $element)
 {
     // store element
     $this->elements[$element->name] = $element;
     // assign default value from bound model
     if ($this->modelAssigned() && isset($this->model->{$element->name})) {
         $element->val($this->model->{$element->name});
     }
     // add observer of "Value changed" event
     $element->observe($this->observer);
 }