Example #1
0
 /**
  * @param string $name
  * @return Button
  * @throws DuplicateButtonException
  */
 protected function addButton($name, $label = NULL)
 {
     if ($name == self::ROW_FORM) {
         $button = new Button($this['buttons'], $name);
         $self = $this;
         $primaryKey = $this->primaryKey;
         $button->setLink(function ($row) use($self, $primaryKey) {
             return $self->link("showRowForm!", $row[$primaryKey]);
         });
     } else {
         if (!empty($this['buttons']->components[$name])) {
             throw new DuplicateButtonException("Button {$name} already exists.");
         }
         $button = new Button($this['buttons'], $name);
     }
     $button->setLabel($label);
     return $button;
 }