How To Collect The Tabular Input

while i am using $this->getItemsToUpdate() while collecting the tabular input but i am getting the error that there is no such method wheather the getItemToUpdate() method to be implemented by us or not

here is my code

view

<div class="row">

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

<?php echo $form->textField($model,‘name’); ?>

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

</div>

<div class="row">

<?php echo $form->labelEx($model,‘surname’); ?>

<?php echo $form->textField($model,‘surname’); ?>

<?php echo $form->error($model,‘surname’); ?>

</div>

<div class="row">

<?php echo $form->labelEx($model,‘email’); ?>

<?php echo $form->textField($model,‘email’); ?>

<?php echo $form->error($model,‘email’); ?>

</div>

<div class="row">

<?php $items = array(1,2); ?>

<?php foreach ($items as $i=>$item): ?>

<?php echo $form->textField($modelAddress, ‘[$i]street’); ?>

<?php echo $form->textField($modelAddress, ‘[$i]city’); ?>

<?php echo $form->textField($modelAddress, ‘[$i]state’); ?>

<?php endforeach; ?>

</div>

then i should collected the data of the modelAddress field in controller

controller

public function actionBatchUpdate()

{

$model = new User;

$modelAddress = new Address;

$items=$this->getItemsToUpdate();

if(isset($_POST[‘Address’]))

{

foreach($items as $i=>$item)

{

if(isset($_POST[‘Address’][$i]))

$item->attributes=$_POST[‘Address’][$i];

$valid=$item->validate() && $valid;

}

if($valid) // all items are valid

// …do something here

}

$this->render(‘batchUpdate’, array(

‘model’ => $model,

‘modelAddress’ => $modelAddress,

));

}

here how to get the items variable count by implementing the getitemtoupdate() method please help me

You have to implement this function in your controller like

public function getitemstoupdate($user_id)

    { 


    //return only models that need update


    &#036;model=Address::model()-&gt;findAll('your condition');


    return &#036;model;


}

but i want to create form , not update. in find all() this will take from db… give me simple code snippet for this. plz

I want to keep track of more than one in 1 table. But the incoming data is only the first data alone with the following code. Could help me.

View:


<?php 

			$siswa=Siswa::model()->findAll();

			foreach ($siswa as $i=>$ii): 

		?>

		<?php echo $form->textFieldRow($model,"[$i]kode_mapel",array('class'=>'span2','maxlength'=>6)); ?>

		<?php echo $form->textFieldRow($model,"[$i]kode_guru", array('class'=>'span2', 'maxlength'=>2)); ?>

	

		<?php echo $form->hiddenField($model,"[$i]lokal",array('value'=>$ii['lokal'])); ?>

		<?php echo $form->hiddenField($model,"[$i]kelas",array('value'=>$ii['kelas'])); ?>

		<?php echo $form->hiddenField($model,"[$i]nisn",array('value'=>$ii['nisn'])); ?>

			<tr>

				<td><?php echo $ii['nisn']; ?></td>

				<td><?php echo $ii['nama_lengkap']; ?></td>

				<td><?php echo $form->textFieldRow($model,"[$i]na", array('class'=>'input-small', 'id'=>'na')); ?></td>

				<td><?php echo $form->textFieldRow($model,"[$i]un", array('class'=>'input-small', 'id'=>'un')); ?></td>

				<td><?php echo $form->textFieldRow($model,"[$i]uas", array('class'=>'input-small', 'id'=>'uas')); ?></td>

			</tr>

		<?php endforeach; ?>

Controller:


public function actionCreate()

	{

		$model=new Nilai;

		if(isset($_POST['Nilai']))

		{

			$valid=true;

			foreach ($_POST['Nilai'] as $i=>$ii){

				if(isset($_POST['Nilai'][$i])){

					$model=new Nilai;

					$model->attributes=$_POST['Nilai'][$i];

					$valid=$model->validate();

					$valid2=$model->validate() && $valid;

					if($valid2){

						$model->save();

						var_dump($model->errors);

					}

					$this->redirect(array('nilai/admin'));

				}

			}

			

		}

$this->render('create',array(

			'model'=>$model,

		));

	}