kartik\tree\TreeView::renderToolbar PHP Méthode

renderToolbar() public méthode

Renders the markup for the button actions toolbar
public renderToolbar ( ) : string
Résultat string
    public function renderToolbar()
    {
        $out = Html::beginTag('div', $this->toolbarOptions) . "\n" . Html::beginTag('div', $this->buttonGroupOptions);
        foreach ($this->toolbar as $btn => $settings) {
            if ($settings === false) {
                continue;
            }
            if ($settings === self::BTN_SEPARATOR) {
                $out .= "\n</div>\n" . Html::beginTag('div', $this->buttonGroupOptions);
                continue;
            }
            $icon = ArrayHelper::getValue($settings, 'icon', '');
            $label = ArrayHelper::getValue($settings, 'label', '');
            $iconOptions = ArrayHelper::getValue($settings, 'iconOptions', []);
            $options = ArrayHelper::getValue($settings, 'options', []);
            $iconOptions = array_replace_recursive($this->buttonIconOptions, $iconOptions);
            $options = array_replace_recursive($this->buttonOptions, $options);
            Html::addCssClass($options, 'kv-toolbar-btn kv-' . $btn);
            if (!empty($icon)) {
                $icon = $this->renderIcon($icon, $iconOptions);
                $label = empty($label) ? $icon : $icon . ' ' . $label;
            }
            if (!empty($settings['url'])) {
                $out .= "\n" . Html::a($label, $settings['url'], $options);
            } else {
                $out .= "\n" . Html::button($label, $options);
            }
        }
        $out .= "</div>\n</div>";
        return $out;
    }

Usage Example

 /**
  * Renders the markup for the button actions toolbar
  *
  * @return string
  */
 public function renderToolbar()
 {
     if (!$this->showToolbar) {
         return '';
     }
     unset($this->toolbar[self::BTN_CREATE], $this->toolbar[self::BTN_CREATE_ROOT], $this->toolbar[self::BTN_REMOVE]);
     return parent::renderToolbar();
 }