Server Side Calculations

Hello, i need to perform some calculations when the user is filling a form and show the result to the user, before he save the record.

In the old days, without YII, i used javascript on the client side.

But now, i want to use the server and the model validation

I was thinking about using the enableAjaxValidation on activeform and afterValidate on the model to achieve this.

But with enableAjaxValidation, the result is a json with all the errors.

My problem is that \yii\widgets\ActiveForm::validate($model) return the errors list and expect that json format.

My ideal solution require that activeform expect a json like


    "errors": {

        "field1": [




    "result1": "...........",

    "result2": "..........."


and then with the activeform afterValidate, i can get the "results" and show them to the user.

Do you know a better way to achieve this ?

Is my solution possible ( without modification of the yii.activeForm.js ) ?

It is possible, for the YII Core Team to make the json result expected, more flexible ?

Sorry for my English

I did something like this, I mean adding extra data to the ajax validation json response and using it in afterValidate:

'afterValidate' => 'js:function($form,data,hasError){}',

where data is the response.

Thanks, i can do that