TbModal widget not working properly

FORM :


<html>

    <head>

        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/styles.css" />

    </head>

    <body>

        

         <?php foreach ($model as $model): ?>

       


        <div class="view form coursemain ">

           

            <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(

                        'id' => 'chnage-password-form',

                        'enableClientValidation' => true,

                        'htmlOptions' => array('class' => 'well'),

                        'clientOptions' => array(

                            'validateOnSubmit' => true,

                        ),

                 ));

            ?>

            

            <br />

            <table class="coursetable">

               

                <tr>

                    

                    <td class="coursetd">

                         <span class="coursetext"> <?php echo CHtml::encode($model->course_name); ?></span>

                

 

                      

                    </td>

                    <td> <?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'myModal')); ?>

                        <div class="modal-header">

                        <a class="close" data-dismiss="modal">&times;</a>

                        <h4>Modal header</h4>

                      </div>

 

                      <div class="modal-body">

    

                        <span class="coursetext"> <?php echo CHtml::encode($model->course_details); ?>

                        <?php echo CHtml::encode($model->session); ?></span>

                      </div>

 

                      <div class="modal-footer">

                        <?php $this->widget('bootstrap.widgets.TbButton', array(

                            'type'=>'primary',

                            'label'=>'Save changes',

                            'url'=>'#',

                            'htmlOptions'=>array('data-dismiss'=>'modal'),

                         )); ?>

                        <?php $this->widget('bootstrap.widgets.TbButton', array(

                            'label'=>'Close',

                            'url'=>'#',

                            'htmlOptions'=>array('data-dismiss'=>'modal'),

                        )); ?>

                    </div>

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

                    </td>

                </tr>

                 

            </table> 

           

                  

            <span class="tdspace"><?php $this->widget('bootstrap.widgets.TbButton', array(

                'label'=>'Register',

                'type'=>'primary',

                'htmlOptions'=>array(

                'data-toggle'=>'modal',

                'data-target'=>'#myModal'),)); ?>

             </span>

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

            

            </div>

        <?php endforeach; ?>

        

            

    </body>

</html>




this is my form.It does not display different modal in each iteration(It shows same database entry i.e.course_details and session for each itearion).Please let me know where to put modal widget exactly in the form.