TbButtonColumn::renderButton PHP Method

renderButton() protected method

Renders a link button.
protected renderButton ( string $id, array $button, integer $row, mixed $data )
$id string the ID of the button
$button array the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements.
$row integer the row number (zero-based)
$data mixed the data object associated with the row
    protected function renderButton($id, $button, $row, $data)
    {
        if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) {
            return;
        }
        $label = isset($button['label']) ? $button['label'] : $id;
        $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#';
        $options = isset($button['options']) ? $button['options'] : array();
        if (!isset($options['title'])) {
            $options['title'] = $label;
        }
        if (!isset($options['rel'])) {
            $options['rel'] = 'tooltip';
        }
        if (isset($button['icon'])) {
            if (strpos($button['icon'], 'icon') === false) {
                $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon']));
            }
            echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options);
        } else {
            if (isset($button['imageUrl']) && is_string($button['imageUrl'])) {
                echo CHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options);
            } else {
                echo CHtml::link($label, $url, $options);
            }
        }
    }

Usage Example

Beispiel #1
0
 protected function renderButton($id, $button, $row, $data)
 {
     $options = isset($button['options']) ? $button['options'] : array();
     if (isset($options['visible']) && !$this->evaluateExpression($options['visible'], array('row' => $row, 'data' => $data))) {
         return;
     }
     return parent::renderButton($id, $button, $row, $data);
 }