public function actionDelete() { $itemId = yii::$app->request->post('item_id'); $variantId = yii::$app->request->post('variant_id'); $fieldId = yii::$app->request->post('field_id'); if ($value = fieldValue::find()->where(['item_id' => $itemId, 'variant_id' => $variantId])->one()) { $value->delete(); } else { FieldValue::deleteAll(['item_id' => $itemId, 'field_id' => $fieldId]); } return json_encode(['result' => 'success']); }
public function deleteValues() { foreach (FieldValue::find()->where(['item_id' => $this->owner->id])->all() as $value) { $value->delete(); } return true; }