当开发者使用模块表单时,可以对一篇内容进行提交子内容,也就是下级内容,如何来判断本次模块表单提交的某个字段例如title是否在当前子内容中重复提交过呢?
需要二次开发模块表单的控制器,例如demo模块的test模块表单
那么,他的模块表单控制器路径是:
dayrui/App/Demo/Controllers/Test.php
<?php namespace Phpcmf\Controllers;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class Test extends \Phpcmf\Home\Mform
{
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('cid', $this->index['id'])
->where('title', $post['title'])->counts()) {
$this->_json(0, 'title字段的值已经存在,不能重复提交');
}
}
$this->_Home_Post();
}
}
上一篇:单独对模块内容字段进行存储
下一篇:自定义上传图片组件的存储过程
有站啦CMS®万能建站系统基于 CodeIgniter4 高性能的开发框架,支持接入Laravel、ThinkPHP三种内核可选,基于MIT开源许可协议,免费且不限制商业使用。 提供PC + 手机 + 微信 + 小程序 + APP API + 多终端一体化网站技术解决方案。