<form action="__APP__/Companyinfo/save" method="post">
<input type="hidden" name="id" id="id" value="<{$id}>"/>
<table width="100%">
<tr>
<td>类型</td>
<td>
<input type="text" name="type" id="type" value="<{$type}>"/>
</td>
</tr>
<tr>
<td></td><td>
<input type="text" name="content" id="content" value="<{$content}>"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="save" id="save" value="保存"/>
</td>
</tr>
</table>
</form>
Action代码是:
$Com=D("Companyinfo"); // 实例化User对象
$result=$Com->create();
if(!$result){
exit($Com->getError());
}
else{
echo 'success';
}
Model 代码是
<?php
class CompanyinfoModel extends Model{
// 设置数据表
protected $tableName = 'Companyinfo';
// 自动验证设置
protected $_validate = array(
array('type','require','用户名必须!', 1),
array('content','require','密码必须!', 1),
);
}
无论我前台的type content输与不输都不进行验证,希望大家帮忙看看!
最佳答案