电话
13363039260
当开发者使用表单时,如何来判断本次表单提交的某个字段例如title是否在当前内容中重复提交过呢?
需要二次开发表单的控制器,例如test全局表单
那么,他的表单控制器路径是:
dayrui/App/Form/Controllers/Test.php
<?php namespace Phpcmf\Controllers;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class Test extends \Phpcmf\Home\Form
{
public function index() {
$this->_Home_List();
}
public function show() {
$this->_Home_Show();
}
public function post() {
if (IS_POST) {
// 这里表示提交之前
$post = \Phpcmf\Service::L('input')->post('data');
if (\Phpcmf\Service::M()->table($this->init['table'])
->where('title', $post['title'])->counts()) {
$this->_json(0, 'title字段的值已经存在,不能重复提交');
}
}
$this->_Home_Post();
}
}