Example #1
0
 /**
  * @param $instance
  * @return string
  */
 protected function button($instance)
 {
     if (!is_null($this->url)) {
         if (is_callable($this->url)) {
             $callback = $this->url;
             $url = $callback($instance);
         } else {
             $url = strtr($this->url, [':id' => $instance->id]);
         }
     } else {
         $url = $this->router->routeToTable($this->modelItem->getAlias(), ['action' => $this->name, 'id' => $instance->id]);
     }
     $attributes = ['class' => 'btn btn-default btn-sm', 'href' => $url, 'data-toggle' => 'tooltip'];
     $content = '';
     if (!is_null($this->icon)) {
         $content .= '<i class="fa ' . $this->icon . '"></i>';
     }
     if ($this->style === 'long') {
         $content .= ' ' . $this->label;
     } else {
         $attributes['title'] = $this->label;
     }
     if (!is_null($this->target)) {
         $attributes['target'] = $this->target;
     }
     return $this->htmlBuilder->tag('a', $attributes, $content);
 }