yii\widgets\DetailView::init PHP Method

init() public method

This method will initialize required property values.
public init ( )
    public function init()
    {
        if ($this->model === null) {
            throw new InvalidConfigException('Please specify the "model" property.');
        }
        if ($this->formatter === null) {
            $this->formatter = Yii::$app->getFormatter();
        } elseif (is_array($this->formatter)) {
            $this->formatter = Yii::createObject($this->formatter);
        }
        if (!$this->formatter instanceof Formatter) {
            throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
        }
        $this->normalizeAttributes();
        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getId();
        }
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (empty($this->attributes)) {
         $this->attributes = $this->attributes();
     }
     parent::init();
 }
All Usage Examples Of yii\widgets\DetailView::init