回锅菜鸟 2014-11-21 13:56:48 2795次浏览 0条回复 0 0 0

使用小物件添加的时候,好像发生了多次请求,使用唯一校验时,每次都会显示唯一,修改也是一样;但是实在不知道是哪里造成的发生多次请求

//faction
public function add(){
        $devicegroup_model  = new DeviceGroup();
	//准备数据
	$aData["devicegroup_model"]=$devicegroup_model;
	//正式添加
	if(isset($_POST['DeviceGroup'])){
		$devicegroup_model -> attributes = $_POST['DeviceGroup'];
		if($devicegroup_model->save()){
			Yii::app()->user->setFlash('success',"设备信息修改成功");
		}
	}		
	//渲染到页面
	$this->_renderWrappedTemplate('devicegroup','devicegroup_add',$aData,'/examine/');
}

//model

public function rules(){
    return array(
        array('devg_name','required','message'=>'地区管理员姓名必须填写'),
        array('devg_name','unique','message'=>'地区管理员姓名已存在'),
        array('description','required','message'=>'该选项必填,可填写例如:该地区管理员负责区域等信息'),
        array('responsible_tel','required','message'=>'请填写真实联系方式,方便沟通'),
        array('responsible_tel','match','pattern'=>'/^1[3|5|7|8|][0-9]{9}$/','message'=>'手机号码格式不正确'),
        array('responsible_IDCard','match','pattern'=>'/^\d{18}|\d{15}$/','message'=>'身份证号格式不正确'),
        array('devg_id,enabled','safe'),
    );
}

//页面

	<?php $form =$this->beginWidget('CActiveForm',array('enableClientValidation'=>true,
			'clientOptions'=>array('validateOnSubmit'=>true,),)); ?>
<table cellpadding="5" cellspacing="3" style="text-align:left; width:100%; ">
	<tr>
		<td align="right" height="22" width=30% >
			<strong>
				<?php echo $form -> label($devicegroup_model, 'devg_name'); ?>
			</strong>
		</td><td  width=3%></td>
		<td colspan="2" align="left"  width=18%>
			<strong>
				<?php echo $form -> textField($devicegroup_model,'devg_name',array('style'=>"width: 220px;")); ?>
			</strong>
		</td>
		<td><?php echo $form ->error($devicegroup_model,'devg_name');  ?></td>
	</tr>
	<tr>
		<td align="right" height="22">
			<strong>
				<?php echo $form -> label($devicegroup_model, 'responsible_tel'); ?>
			</strong>
		</td><td></td>
		<td colspan="2" align="left">
			<strong>
				<?php echo $form -> textField($devicegroup_model,'responsible_tel',array('style'=>"width: 220px;")); ?>
			</strong>
		</td>
		<td><?php echo $form ->error($devicegroup_model,'responsible_tel');  ?></td>
	</tr>
	<tr>
		<td align="right" height="22">
			<strong>
				<?php echo $form -> label($devicegroup_model, 'responsible_IDCard'); ?>
			</strong>
		</td><td></td>
		<td colspan="2" align="left">
			<strong>
				<?php echo $form -> textField($devicegroup_model,'responsible_IDCard',array('style'=>"width: 220px;",'value'=>'000000000000000000')); ?>
			</strong>
		</td>
		<td><?php echo $form ->error($devicegroup_model,'responsible_IDCard');  ?></td>
	</tr>
	<tr>
		<td align="right" height="22">
			<strong><?php echo $form -> label($devicegroup_model, 'description') ?></strong>
		</td><td></td>
		<td align="left">
			<?php echo $form -> textArea($devicegroup_model, 'description',array('cols'=>50,'rows'=>5)) ?>
		</td>
	</tr>
	<tr>
		<tr><td></td><td></td>
			<td colspan="2" align="right">
				<input type="submit" value="添加" />
			</td>
		</tr>
	</tr>
</table>
<?php $this -> endwidget(); ?> 
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册