| 插件 | 模块内容表单 V1.28 |
| 应用作者 | 迅睿官方团队 |
| 发布时间 | 2021-03-24 10:40:39 |
| 更新时间 | 2024-12-03 23:39:33 |
官方表单辣手的问题,比如我要做一个报名系统,主题ID1的 quota 是设定的最大报名量,roster_total 是系统记录报名数量(自动统计的)

如果我设置id1的报名是50人,然后系统报名到50人了。怎么让人家不能再从前台报名了呢?
我自己写了模块表单的文件 \dayrui\App\baoming\Controllers\Roster.php 在提交前增加了一个控制判断,可是还是不成功,达到最大量了,还是能报名。
<?php namespace Phpcmf\Controllers;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class Roster extends \Phpcmf\Home\Mform
{
public function index() {
$this->_Home_List();
}
public function show() {
$this->_Home_Show();
}
public function post() {
// 提交前的操作
if(IS_POST){
$a = \Phpcmf\Service::L('input')->get();
$b = \Phpcmf\Service::M()->db->table(SITE_ID.'_baoming')->get($a['cid'])->getRowArray();
$c = $b['roster_total'];
$d = $b['quota'];
$e = \Phpcmf\Service::M()->table(SITE_ID.'__baoming_form_roster')->where('cid', intval($a['cid']))->where('status', 1)->counts();
if ($c >= $d){
$this->_json(0, '提交失败,已超过报名人数');
}
}
// 提交处理
$this->_Home_Post();
}
}另外希望官方能协助帮忙一下,怎么完善在内容ID1的baoming表单里面,限制表单的title不能重复,因为不做这个现在官方的表单文件,人家提交的时候,按10下,就会有10个重复的表单提交。
应用版权:官方
应用名称:模块内容表单
$e = \Phpcmf\Service::M()->table(SITE_ID.'_baoming_form_roster')->where('cid', intval($this->index['id']))->where('status', 1)->counts(); if ($e >= $this->index['roster_total']){ $this->_json(0, '提交失败,已超过报名人数'); }牛!!要是能在解决 同一个内容下 表单 的 title 不可以重复就更好了!
if (\Phpcmf\Service::M()->table(SITE_ID.'_baoming_form_roster')->where('title', $_POST['data']['title'])->counts()){ $this->_json(0, '提交失败,标题重复了'); }if (\Phpcmf\Service::M()->table(SITE_ID.'_baoming_form_roster')->where('cid', intval($this->index['id']))->where('title', $_POST['data']['title'])->counts()){if (\Phpcmf\Service::M()->table(SITE_ID.'_baoming_form_roster')->where('cid', intval($this->index['id']))->where('title', $_POST['data']['title'])->counts()){改成这个后 不成功了,还是能疯狂的点击 重复提交。$e = \Phpcmf\Service::M()->table(SITE_ID.'_baoming_form_roster')->where('cid', intval($this->index['id']))->where('status', 1)->counts(); if ($e >= $this->index['roster_total']){ $this->_json(0, '提交失败,已超过报名人数'); }修改成这个 还是不成功,超过人数还是能继续提交……