Question

I have the following code in my main index.php:

<div class="form">
<?php $oForm = $this->beginWidget('CActiveForm', array(
'id' => 'test-form',
'enableAjaxValidation' => false,
'enableClientValidation' => true,
'clientOptions' => array(
    'validateOnSubmit' => true,
),
'focus' => array($oTest, 'title'),
)); ?>

<fieldset>
    <legend>Questions</legend>
    <div id="questions">
        <?php echo $oForm->hiddenField($oTest, '_id');  ?>
        <?php $this->renderPartial('_showQuestions', array('oTest' => $oTest)); ?>
    </div>
</fieldset>

<fieldset>
    <legend>Reviewers</legend>
    <div class="row">
        <?php echo $oForm->labelEx($oTest, 'reviewers'); ?>
        <?php echo $oForm->textField($oTest, 'reviewers', array('size' => 140)); ?>
    </div>
</fieldset>
<?php $this->endWidget(); ?>

and the following code in the partial view _showSuestions

<div class="form">
<?php $oForm = $this->beginWidget('CActiveForm', array(
'id' => 'question-form2',
'enableAjaxValidation' => false,
'enableClientValidation' => true,
'clientOptions' => array(
    'validateOnSubmit' => true,
),
)); ?>
<?php echo $oForm->hiddenField($oTest, '_id'); ?>

<?php
foreach ($oTest->questions as $oQuestion)
{
    var_dump($oQuestion);
}
?>



<?php $this->endWidget(); ?>

Now the problem is that this doesn't work. When I fisit my page, the form tag is suddenly closed after I called my partialView. i'm guessing this is because of the nested CActiveForm? When I remove the inner CActiveForm it works

Was it helpful?

Solution

try changing the name of the second form variable (in _showQuestions file), say, oForm to tForm. there is a variable name clash. Because at the end of the day, renderPartial is nothing but a include.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top