0
votes

I have the following error

Class 'app\controllers\ActiveForm' not found

when submit the following ActiveForm (kartik\widgets\ActiveForm)

$form = ActiveForm::begin([
    'type'=>ActiveForm::TYPE_VERTICAL,
    'action' => 'incarico/update/'.$model->id,
    'enableAjaxValidation' => true,
    'enableClientValidation' => false,
]);

My controller has this action:

public function actionUpdate($id)
{

    $model = $this->findModel($id);

    if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
        Yii::$app->response->format = Response::FORMAT_JSON;
        return ActiveForm::validate($model);
    } else {
        return $this->render('update', [
            'model' => $model,
        ]);
    }

}

The error refers to this line

return ActiveForm::validate($model);
1

1 Answers

2
votes

Because you haven't include ActiveForm namespace yet.

add this in the use section (in the beginning of that file)

use kartik\widgets\ActiveForm;