Search code examples
yiirenderpartial

Yii: include form inside form


There's a way to include form inside another form using the same action? I tried with renderPartial but doesn't work. eg:

$this->renderPartial('//utente/_form', array('model'=>new User, 'condition'=>$condition, 'form' => $form, 'rule' => '3'), false, true);


Solution

    1. Use renderPartial(with return=true) to render result of first for in temporal variable.
    2. Use the variable in second view.

    See CController renderPartial() for details

    $form1 = $this->renderPartial('firstView', $data1, true);
    
    $this->renderPartial(
        '//utente/_form',
        array(
            'model'=>new User,
            'condition'=>$condition,
            'form' => $form,
            'rule' => '3',
            'form1' => $form1
        ),
        false,
        true
    );