TP5为什么表单提交来的数据为空
publicfunctiondoAdd(Request$request){//从提交表单中获取数据$data=$request->param();dump($data);...
public function doAdd(Request $request)
{
//从提交表单中获取数据
$data = $request->param();
dump($data);
//更新当前记录
$result = Info_tb::create($data);
//设置返回数据的初始值
$status = 0;
$message = '添加失败,请检查';
//检测更新结果,将结果返回给info_edit模板中的ajax提交回调处理
if (true == $result) {
$status = 1;
$message = '恭喜, 添加成功~~';
}
//自动转为json格式返回
return ['status'=>$status, 'message'=>$message];
}
<form action="" method="post" class="form form-horizontal" id="form-admin-add">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" class="input-text" value="" placeholder="" id="name" name="name">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户密码:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码为6位" id="password" name="password">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3">启用状态:</label>
<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
<select class="select" name="status" size="1">
<option value="1" selected>启用</option>
<option value="0">不启用</option>
</select>
</span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="email" class="input-text" placeholder="@" name="email" id="email" value="">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3">角色:</label>
<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
<select class="select" name="role" size="1">
<option value="0" selected>管理员</option>
<option value="1" >超级管理员</option>
</select>
</span>
</div>
</div>
<div class="row cl">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
<input class="btn btn-primary radius disabled" type="button" value=" 提交 " id="submit" >
</div>
</div>
</form> 展开
{
//从提交表单中获取数据
$data = $request->param();
dump($data);
//更新当前记录
$result = Info_tb::create($data);
//设置返回数据的初始值
$status = 0;
$message = '添加失败,请检查';
//检测更新结果,将结果返回给info_edit模板中的ajax提交回调处理
if (true == $result) {
$status = 1;
$message = '恭喜, 添加成功~~';
}
//自动转为json格式返回
return ['status'=>$status, 'message'=>$message];
}
<form action="" method="post" class="form form-horizontal" id="form-admin-add">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" class="input-text" value="" placeholder="" id="name" name="name">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户密码:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码为6位" id="password" name="password">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3">启用状态:</label>
<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
<select class="select" name="status" size="1">
<option value="1" selected>启用</option>
<option value="0">不启用</option>
</select>
</span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="email" class="input-text" placeholder="@" name="email" id="email" value="">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3">角色:</label>
<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
<select class="select" name="role" size="1">
<option value="0" selected>管理员</option>
<option value="1" >超级管理员</option>
</select>
</span>
</div>
</div>
<div class="row cl">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
<input class="btn btn-primary radius disabled" type="button" value=" 提交 " id="submit" >
</div>
</div>
</form> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询