表单提交多个相同模型数据 [ 2.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>
hiccup_yin 枣庄
注册时间:2016-01-24
最后登录:2016-06-19
在线时长:6小时0分
最后登录:2016-06-19
在线时长:6小时0分
- 粉丝5
- 金钱75
- 威望30
- 积分435
共 0 条评论