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>

	<p>

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

	</p>

	<p>Some more  Text</p>

	<p>

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

	</p>

	<p>Little More Text</p>

	<p>

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

	</p>

my _form.php is like this:


<div class="form">


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

	'id'=>'settings-form',

	'enableAjaxValidation'=>false,

)); ?>


	<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>


	<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>


	<div class="row buttons">

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

	</div>


<?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

Regards

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

http://www.yiiframework.com/doc/guide/1.1/en/form.table

Thanks all :)

Solved link is here with code :)