Пример #1
0
 public function setAttribute($attribute, $value = null)
 {
     if ($this->getTagName() === 'textarea' && $attribute === 'value') {
         return $this->addText($value);
     }
     $keys = array('select' => 'selected', 'checkbox' => 'checked', 'radio' => 'checked');
     if (isset($keys[$this->getOriginalTagName()]) && $attribute === 'value') {
         foreach ($this->children() as $child) {
             if ($child->getAttribute('value') == $value) {
                 $verb = $keys[$this->getOriginalTagName()];
                 $child->setAttribute($verb, $verb);
                 return;
             }
         }
     }
     return parent::setAttribute($attribute, $value);
 }