/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(GalleryFile::className(), ['galleryId' => 'id'])->orderBy(['position' => SORT_ASC]); }
public function actionCaption() { Yii::$app->response->format = Response::FORMAT_JSON; if (!Yii::$app->request->isAjax) { throw new BadRequestHttpException(); } $response = false; $model = GalleryFile::findOne(Yii::$app->request->post('id')); $model->caption = Yii::$app->request->post('caption'); if ($model->save()) { $response = ['status' => true, 'message' => 'Success']; } return $response; }