using ajax to load views inside activeForm

I have an active form widget and when somebody clicks on a button in the form I want to display the data from a partial view, and if it’s already shown, then I want to hide it/remove it.

When the form get’s submitted, I only care about the fields that are shown and filled in from the partial view.


<?php echo CHtml::ajaxButton('Box1', $this->createUrl('box1'), array('update' => '#box1')); ?>

<div class="form">

  <?php $form=$this->beginWidget('CActiveForm', array(



  )); ?>

  <div id="box1">


  <div id="box2">


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

</div><!-- end form -->


public function actionBox1() {



_box1.php (_box2 would be the same/similar)


  <div class="row">

    <?php echo $form->labelEx($model,'box_message'); ?>

    <?php echo $form->textArea($model,'box_message'); ?>

    <?php echo $form->error($model,'box_message'); ?>



Did you manage to solve that?

I am trying to do just the same thing but with no luck…

Can you plz explain the basics of solving this?

Any help is appreciated!