Yii Framework Forum: Creating And Saving Datas Into 2 Models - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Creating And Saving Datas Into 2 Models Rate Topic: -----

#1 User is offline   adri00713 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 28-January 13

Posted 01 February 2013 - 01:27 PM

ON MY CONTROLLER

public function actionCreate() {
		
		Yii::import('application.modules.pims.modules.supplies.models.BaseSiReceivedItem');
		$model=new BaseRefSiDetails;
		$model2=new BaseSiReceivedItem;
		
        $valid=true;
		        foreach($items as $i=>$item)
		        {
		            if(isset($_POST['BaseRefSiDetails'][$i]))
		                $item->attributes=$_POST['BaseRefSiDetails'][$i];
		
		        }
		
		$this->render('create',array(
		'model'=>$model,
		'model2'=>$model2,
		'items'=>$item,
		));
		
		
	}


<?php $form=$this->beginWidget('CActiveForm', array(
		'id'=>'new-base-ref-si-details-form',
		'method'=>'post',
		'action'=>array('create'),
)); ?>

<span class="form-title">New Entry</span>
<div class="form offpage">
	<table>
	<?php foreach($item as $i=>$item): ?>
		<tr><td></td><td><p class="note">Fields with <span class="required">*</span> are required.</p></td></tr>
		<tr>
			<td><?php echo $form->labelEx($model,'Stock No'); ?></td>
			<td>	
				<?php echo $form->textField($model,'[$i]stockno',array('size'=>60,'maxlength'=>1000,'id'=>'new-base-ref-si-details-stockno','disabled'=>'')); ?>
				<?php echo $form->error($model,'stockno'); ?>
			</td>
		</tr>			

		<tr>
			<td><?php echo $form->labelEx($model,'Classification'); ?></td>
			<td>
				<?php echo $form->dropDownList($model,'[$i]classification',BaseRefSiDetails::getOptionclassification(),array('empty'=>'')); ?>
				<?php echo $form->error($model,'classification'); ?>
			</td>
		</tr>	
		<tr>
			<td><?php echo $form->labelEx($model,'Article Code'); ?></td>
			<td>	
				<?php echo $form->textField($model,'[$i]articlecode',array('size'=>60,'maxlength'=>1000,'id'=>'new-base-ref-si-details-articlecode','disabled'=>'')); ?>
				<?php echo $form->error($model,'articlecode'); ?>
			</td>
		</tr>	
		<tr>
			<td><?php echo $form->labelEx($model,'Description'); ?></td>
			<td>	
				<?php echo $form->textField($model,'[$i]description',array('size'=>60,'maxlength'=>1000,'id'=>'new-base-ref-si-details-description','disabled'=>'')); ?>
				<?php echo $form->error($model,'description'); ?>
			</td>
		</tr>	
	<?php endforeach; ?>
		<tr>	
			<td></td>	
			<td>
				<?php echo CHtml::submitButton('Create');?>				<?php echo CHtml::button('Cancel',array('onclick'=>'window.location.href = "'.$this->createUrl('index').'";')); ?>
			</td>
		</tr>
	</table>
</div><!-- form -->

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





when i tried to create a new item it will just redirect to a page containing my model's name
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users