hiccup_yin 2016-02-11 11:41:25 5026次浏览 0条评论 0 0 0

当使用一个表单提交多个模型数据时, 参照官方文档,在model 的属性前面加上[$index],这样可以避免只提交最后一个数据

<div class='edu'>
<h1>Education Experience</h1>
<?php
	use dosamigos\datepicker\DatePicker;
	use yii\widgets\ActiveForm;
	use yii\helpers\Html;
	$form = ActiveForm::begin([
			'id'=>'edu-exp',
			'enableAjaxValidation'=>false,
	]);
?>
->1
<?=$form->field($edu_1,'[1]date_begin')->widget(DatePicker::className(),[
//		'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('start time')?>
<?=$form->field($edu_1,'[1]date_end')->widget(DatePicker::className(),[
	//	'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('end time')?>

<?=$form->field($edu_1,'[1]university') ?>
<?=$form->field($edu_1,'[1]department')?>
<?=$form->field($edu_1,'[1]degree')?>
<?=$form->field($edu_1,'[1]teacher')?>


->2
<?=$form->field($edu_2,'[2]date_begin')->widget(DatePicker::className(),[
//		'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('start time')?>
<?=$form->field($edu_2,'[2]date_end')->widget(DatePicker::className(),[
	//	'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('end time')?>

<?=$form->field($edu_2,'[2]university') ?>
<?=$form->field($edu_2,'[2]department')?>
<?=$form->field($edu_2,'[2]degree')?>
<?=$form->field($edu_2,'[2]teacher')?>


->3
<?=$form->field($edu_3,'[3]date_begin')->widget(DatePicker::className(),[
//		'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('start time')?>
<?=$form->field($edu_3,'[3]date_end')->widget(DatePicker::className(),[
	//	'inline'=>true,
		'template'=>'{addon}{input}',
		'language'=>'zh-CN',
		'clientOptions'=>[
			'autoclose'=>true,
			'format'=>'yyyy-mm-dd',
],
		
])->label('end time')?>

<?=$form->field($edu_3,'[3]university') ?>
<?=$form->field($edu_3,'[3]department')?>
<?=$form->field($edu_3,'[3]degree')?>
<?=$form->field($edu_3,'[3]teacher')?>

<?=Html::submitButton('Submit')?>
</div>
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册