webman-admin后台管理字典设置添加一直提示:字典名称只能是字母数字的组合(bug反馈)

不败少龙

问题描述

默认的字典名: dict_name是有下划线,添加和编辑一直提示错误: 字典名称只能是字母数字的组合

程序代码或配置

在正则校验规则中修改成 "/^[a-zA-Z0-9_]+$/"

    /**
     * 插入
     * @param Request $request
     * @return Response
     * @throws BusinessException|Throwable
     */
    public function insert(Request $request): Response
    {
        if ($request->method() === 'POST') {
            $name = $request->post('name');
            if (Dict::get($name)) {
                return $this->json(1, '字典已经存在');
            }
            if (!preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
                return $this->json(2, '字典名称只能是字母数字的组合');
            }
            $values = (array)$request->post('value', []);
            Dict::save($name, $values);
        }
        return raw_view('dict/insert');
    }

    /**
     * 更新
     * @param Request $request
     * @return Response
     * @throws BusinessException|Throwable
     */
    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            $name = $request->post('name');
            if (!Dict::get($name)) {
                return $this->json(1, '字典不存在');
            }
            if (!preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
                return $this->json(2, '字典名称只能是字母数字的组合');
            }
            Dict::save($name, $request->post('value'));
        }
        return raw_view('dict/update');
    }

操作系统环境及workerman/webman等具体版本

webman2.1,webman_admin2.0

106 1 0
1个回答

感谢反馈,下个版本修复

  • 暂无评论
×
🔝