[SOLVED] How to associate model with sub-form?

Hi,

I’m using Form Builder to create a form consisting of two sub-forms. Each sub-form is associated with a different model.

The form is represented by the following array:


return array(

    'elements'=>array(

        'users'=>array(

            'type'=>'form',

            'title'=>'Gebruikersinformatie',

            'model'=>'Users',                     <------------------

            'elements'=>array(

                'first_name'=>array(

                    'type'=>'text',

                ),

                ...

                'mail_optin'=>array(

                    'type'=>'checkbox'

                )

            )

        ),

        'accounts'=>array(

            'type'=>'form',

            'title'=>'Accountinformatie',

            'model'=>'Accounts',                 <------------------

            'elements'=>array(

                'title'=>array(

                    'type'=>'text',

                ),

                ...

                'bank_account_number'=>array(

                    'type'=>'text'

                )

            )

        )

    ),


    'buttons'=>array(

        'register'=>array(

        ...

    )

);



This confiduration generates an error, similar to the error if no model is associated

with the form. What am I doing wrong and how should I associate a model to a (sub)form?

Thanks

The model assignments are not part of the structure of the (sub)form. If you want to associate models with the sub-forms, use the following assignments after calling CForm():




$form = new CForm('application.views.accounts.registerAccountForm');

$form['users']->model = new Users;

$form['accounts']->model = new Accounts;