private function checkIfFileBehaviorIsAttached() { $behaviors = $this->model->behaviors; foreach ($behaviors as $behavior) { if ($behavior::className() === FileBehavior::className()) { return true; } } $model = $this->model; throw new \Exception("To use FileUpload widgets, FileBehavior should be attached to the {$model::className()}."); }
public function behaviors() { return array_merge(parent::behaviors(), [['class' => FileBehavior::className(), 'groups' => ['image' => ['type' => FileBehavior::TYPE_IMAGE]]]]); }
public function behaviors() { return array_merge(parent::behaviors(), [TimestampBehavior::className(), ['class' => FileBehavior::className(), 'groups' => ['image' => ['type' => FileBehavior::TYPE_IMAGE, 'rules' => ['extensions' => ['png', 'jpg', 'jpeg'], 'maxSize' => 1024 * 1024]]]]]); }