Passing Data To Bootstrap Modal

Hi All,

I currently have a customized grid view. On clicking edit, the modal pops up which consists of data of the user so that the user can edit the data. However I am running into a problem that the id does not get changed in the modal and doesn’t load different data for users when clicked on edit. Any edit button you click, it loads the same data. Here’s the code.




<tbody>

<?php foreach ($users as $user) { ?>

<tr>

	<td>

	   <?php echo $user['ID']; ?>

	</td>

	<td>

		<?php echo $user['user_name']; ?>

	</td>

	<td>                                    

		<a data-toggle="modal" id="edit_user" href="<?php echo Yii::app()->createUrl('users/index', array('id' => $user['ID']));?>" class="btn">Edit</a>															

	</td>													

</tr>

<?php } ?>

</tbody>


<div id="edit_user" class="modal fade" tabindex="-1" data-width="760">

	<div class="modal-body">

		<?php $this->renderPartial('_add_user'); ?>

	</div>

</div>



Please do let me know if anyone tried similar things before.

Cheers.

You need to recreate model every time you load it, otherwise its content is cached (this is by design).