Multimodelform Extension And Ajax Validation

Is it possible tu use Ajax Validation in a form created with the Multimodelform extension?

I’m trying to do it calling:

$this->performAjaxValidation(array($a,$<img src='' class='bbc_emoticon' alt='B)' />);

It works for me when I use two models in a CActiveForm as here described http://www.yiiframew…dation-edition/, but it is not working when I use the Multimodelform extension.

Thank you

[color="#006400"]/* useless poll removed */[/color]

I’m using the multimodelform extension.

But I’m struggling with the following problem:

I want to use ajax validation.

[b]The problem now is: How can I get the controller to validate the multimodelform and (if there is no child-model or not all required fields are filled), to display the error-summary as well for the multimodelform-fields ?


With this code it only highlights only the fields in the main model if not valid…

Further Explanation:

  • There are 2 models: Document and Documentpos

  • I’m using a function “LoadForm” to load the subform into the create form.

  • The sub-view which contains the Document-Form and the Multimodelform for Documentpos looks like following:

$form = $this->beginWidget(

    'GxActiveForm', array(

    'id' => 'document-form',

    'action' => '' . $currentAction . '/id/' . $id,

    'enableAjaxValidation' => true,



 public function actionCreate()



        $deleteItems = '';

        $formName = '';

        $currentAction = Yii::app()->session['currentAction'];

        $document = new Document;

        $documentpos = new Documentpos;

        $validatedDocumentpos = array();

        $errorIndex = null;

        $masterValues = array('dcp_dcid' => $document->dc_id);

        if (Yii::app()->getRequest()->getIsAjaxRequest()) {

            echo CActiveForm::validate(array($document));

          //  echo MultiModelForm::validate($documentpos, $validatedDocumentpos, $deleteItems, $masterValues);

            $errors = $document->getErrors();

            if ($errors) {

                ChromePhp::error('errors: ' . print_r($errors, true) . '<br/>' . $document->dc_id);

            } else {

                ChromePhp::info('output:>>> ' . $document->dc_id);




        if (isset($_POST['Document'])) {

            $document->attributes = $_POST['Document'];

            $detailOK = MultiModelForm::validate($documentpos, $validatedDocumentpos, $deleteItems, $masterValues);

            if ( //validate detail before saving the master

                $detailOK == true

            ) {

                if (MultiModelForm::validate($documentpos, $validatedDocumentpos, $deleteItems, $masterValues)) {

                    if ($detailOK && empty($validatedDocumentpos)) {

                        Yii::app()->user->setFlash('error', 'No detail submitted ');

                        $detailOK = false;

                    } else {

                        if ($document->save()) {

                            MultiModelForm::save($documentpos, $validatedDocumentpos, $deleteItems, $masterValues);

                            $this->redirect(array('update', 'id' => $document->dc_id));


                        Yii::app()->user->setFlash('info', 'OK Detail submitted & saved');

                        $detailOK = true;






            'create', array(

                'formName' => $formName,

                'model' => $document,

                'validatedItems' => $validatedDocumentpos,

                //submit the documentpos and validatedDocumentpos to the widget in the edit form

                'documentpos' => $documentpos,

                'currentAction' => $currentAction,




Can someone help me with this? I just don’t get it after hours and hours (already weeks).