<?php $form=ActiveForm::begin([
'fieldConfig'=>['template'=>'<div class="layui-input-block">{label}{input}{error}</div>'],
'options'=>[
'id'=>'form_adminmenuadd',
'style'=>'margin-top:15px;',
],
]); ?>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($pmodel,'id')->dropDownList($list,[
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入菜单名称"])->label('父级菜单') ?>
</div>
<?php echo $form->field($model,'id')->hiddenInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入菜单名称"])->label('父级菜单') ?>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'name')->textInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入菜单名称"]) ?>
</div>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'id')->textInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入菜单名称"]) ?>
</div>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'link')->textInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入链接地址"]) ?>
</div>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'icon')->textInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入图标"]) ?>
</div>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'sort')->textInput([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required",
"placeholder"=>"请输入图标"]) ?>
</div>
<div class="layui-form-item layui-col-md8">
<div class="layui-input-block">
<?php echo $form->field($model,'isurl')->inline()->radioList(['1'=>'是','0'=>'否']) ?>
</div>
</div>
<div class="layui-form-item layui-col-md8">
<div class="layui-input-block">
<?php echo $form->field($model,'isblank')->inline()->radioList(['1'=>'是','0'=>'否']) ?>
</div>
</div>
<div class="layui-form-item layui-col-md8">
<div class="layui-input-block">
<?php echo $form->field($model,'state')->inline()->radioList(['1'=>'正常','0'=>'禁用']) ?>
</div>
</div>
<div class="layui-form-item layui-col-md8">
<?php echo $form->field($model,'remark')->textArea([
"class"=>"layui-input",
"autocomplete"=>"off",
"lay-verify"=>"required|email",
"placeholder"=>"备注信息"]) ?>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<a onclick="menuAdd();" class="layui-btn" lay-filter="formDemo">立即提交</a>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
<?php ActiveForm::end();?>
小弟请问在座的老师们,更新数据,通过POST提交一个表单,每次都要指定updateAll([‘name’=>$this->name,’pid’=>$this->pid,’isurl’=>$this->isurl,……],'{条件….}’),,,,,,,每个字段都要写进updateAll里面,如果我的表单有几十个值,那得写几十个参数~有没有什么办法能一次性修改为表单提交的所有值呢????
你使用的已经是
$form->field($model, 'attribute');
的形式了,应该清楚模型更新方式的吧。。。
片段代码如下
可以参考Gii 生成的 CRUD 中 update的源码
同意楼上说法