TbDetailView::init PHP Method

init() public method

Initializes the widget.
public init ( )
    public function init()
    {
        parent::init();
        $classes = array('table');
        if (isset($this->type)) {
            if (is_string($this->type)) {
                $this->type = explode(' ', $this->type);
            }
            $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED);
            if (!empty($this->type)) {
                foreach ($this->type as $type) {
                    if (in_array($type, $validTypes)) {
                        $classes[] = 'table-' . $type;
                    }
                }
            }
        }
        if (!empty($classes)) {
            $classes = implode(' ', $classes);
            if (isset($this->htmlOptions['class'])) {
                $this->htmlOptions['class'] .= ' ' . $classes;
            } else {
                $this->htmlOptions['class'] = $classes;
            }
        }
    }

Usage Example

 /**
  *### .init()
  *
  * Widget initialization
  */
 public function init()
 {
     if (!$this->data instanceof CModel) {
         throw new CException('Property "data" should be of CModel class.');
     }
     parent::init();
 }
All Usage Examples Of TbDetailView::init
TbDetailView