Multiple Forms For Single Model

Hi All,

I have a model(table with 2 fields name(pk) and text). I need to show the data in these forms and update it from the page.

I’m able to show the form by using this

	<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

but how to show the content from the table into each section and how to update the data.

index.php is like this:

<p>some & Text</p>


		<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>


	<p>Some more  Text</p>


		<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>


	<p>Little More Text</p>


		<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>	


my _form.php is like this:

<div class="form">

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



)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">

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

		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>

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


	<div class="row">

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

		<?php echo $form->textArea($model,'text',array('rows'=>6, 'cols'=>50)); ?>

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


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Save'); ?>


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

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

What should be my url for the index.php inorder to show the content from the table.(at the moment i’m using localhost/webapp/controller… and its displaying with form 3 times.

Many Thanks in advance

Dear Friend

Kindly check the following thread.

I have made an attempt in creating and updating the parent model and child models in batch mode.

Dynamic Tabular Input


Thanks for your reply seenivasan, but I’m using only one model. that is not related to any other model also. my index.php has some sections and for each section i need to store the name and text. it is like multiple forms and only one model.

multiple forms(same form for each section). in each section i need to show name and text and I need to provide update button so that user can make any change in the text for any section.

you can see my code in my post.

Many Thanks

@ seenivasan: thanks friend… thanks for the Idea… I’m able to achieve what I’m looking for with

Collecting Tabular Input

Thanks all :)

Solved link is here with code :)