hi to all, how can i validate my tabular input
here is my code
view:
<?php for($x = 0; $x < 5; $x++){?>
<?php echo $form->dropDownListRow($model,"[$x]room_id", CHtml::listData(Room::model()->findAllByAttributes(array('bldg_id'=>$hdr->sched->bldg_id)), 'id','room'), array('empty'=>'Select Room'));?>
<?php echo $form->labelEx($model,"[$x]time"); ?>
<?php $this->widget('CMaskedTextField',
array(
'mask'=>'99:99 aa',
'model'=>$model,
'attribute'=>"[$x]time",
'htmlOptions'=>array(
'class'=>'input-small',
),
)); ?>
<?php echo $form->dropDownListRow($model,"[$x]type",$model->getTypeOptions(),array('empty'=>'Select Type'));?>
<?php echo $form->textAreaRow($model,"[$x]observation",array('class'=>'span3', 'rows'=>1,'placeholder'=>'Placeholder content')); ?>
<br>
<?php } ?>
my controller:
if(isset($_POST['MonitoringDtl']))
{
foreach($_POST['MonitoringDtl'] as $i=>$dtl){
$model=new MonitoringDtl;
$model->attributes=$_POST['MonitoringDtl'][$i];
$model->monitoring_hdr_id = $this->_modelhdr->id;
if(preg_match('/^(0[1-9]|1[012])<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />[0-5][0-9]) ((A|P)M)$/i', $model->time)) {
$model->time = date("H:i:s", strtotime($model->time));
}else{
$model->addError('time', 'Invalid time from Format');
}
if($model->save()){
Yii::app()->user->setFlash('success', "Data successfuly save!");
}
}
$this->redirect(array('MonitoringHdr/create'));
}