💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
1.后台核心代码 ~~~ public function save($pid=0) { if ($this->request->isPost()) { $data=$this->request->param(); foreach (explode("\r\n", $data['titles']) as $key => $value) { $inserts[$key]['title']=$value; $inserts[$key]['pid']=$pid; } if(model('PartsClass')->allowField(true)->saveall($inserts)){ $this->success('添加成功'); } $this->success('添加失败'); } } ~~~ 2.前台核心代码 ~~~ {extend name="base" /} {block name="body"} <div class="layui-body"> <!--tab标签--> <div class="layui-tab layui-tab-brief"> <ul class="layui-tab-title"> <li class=""><a href="{:url('index')}">配件分类</a></li> <li class="layui-this">添加分类</li> </ul> <div class="layui-tab-content"> <div class="layui-tab-item layui-show"> <form class="layui-form form-container" action="{:url('save')}" method="post"> <div class="layui-form-item"> <label class="layui-form-label">分类名称</label> <div class="layui-input-block"> <textarea name="titles" placeholder="一行一个" class="layui-textarea"></textarea> </div> </div> <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" lay-submit lay-filter="*">保存</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button> </div> </div> <input type="hidden" name="pid" value="{$Request.param.pid|default=0}"> </form> </div> </div> </div> </div> {/block} {block name="script"} <script> $(document).ready(function() { $("#zm").change(function(event) { $("#zm").val($(this).val().toUpperCase()); }); }); </script> {/block} ~~~ 3.示例图 ![](https://box.kancloud.cn/5aac8e2aa5b28281e88c8ac83b264032_348x215.png)