新手,关于自动验证无效的问题

浏览:587 发布日期:2013/04/15 分类:求助交流
Tpl代码是:
<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输与不输都不进行验证,希望大家帮忙看看!
最佳答案
评论( 相关
后面还有条评论,点击查看>>