Closed taobali32 closed 3 years ago
v2.0.18-beta
89行image字段(form1.help_wechat_qrcode),29行打印提交的数据(dd($data);)
form1.help_wechat_qrcode
dd($data);
<?php namespace App\Admin\Controllers; use App\Http\Controllers\Controller; use App\Models\Config; use Dcat\Admin\Layout\Content; use Dcat\Admin\Layout\Row; use Dcat\Admin\Widgets\Form; use Dcat\Admin\Widgets\Tab; use Dcat\Admin\Http\JsonResponse; class SettingController extends Controller { protected $f = [ 'form1' => 'base_config' ]; public function index(Content $content) { if (request()->getMethod() == 'POST') { $post = request()->all(); // dd($post); if (isset($post['form1'])){ $data = $post['form1']; dd($data); $f = Config::query()->where('type',$this->f['form1'])->first(); if ($f){ Config::query()->where('type',$this->f['form1'])->update(['config' => $data]); }else{ Config::create([ 'type' => $this->f['form1'], 'remark' => '基础设置', 'config' => $data ]); } } return JsonResponse::make()->success('操作成功'); } $content->row(function (Row $row) { $type = request('_t', 1); $tab = new Tab(); if ($type == 1) { $tab->add('基本设置', $this->form1()); // $tab->addLink('Form-2', request()->fullUrlWithQuery(['_t' => 2])); } else { $tab->addLink('基本设置', request()->fullUrlWithQuery(['_t' => 1])); // $tab->add('Form-2', $this->form2(), true); } $row->column(12, $tab->withCard()); }); return $content->header('系统设置'); } protected function form1() { $form = new Form(); $form->action(request()->fullUrl()); $config = Config::query()->where('type',$this->f['form1'])->first(); if ($config){ $body = $config->config; if (!isset($body['help_wechat_qrcode'])){ $body['help_wechat_qrcode'] = ''; } }else{ $body = [ // 'day_price' => 0, // 'max_rise' => 0, 'cny_price' => 0, 'help_wechat_qrcode' => '' ]; } $form->decimal('form1.cny_price', '人民币价格')->required()->default($body['cny_price'] ?? 0)->help('美元对人民币价格'); // $form->image('form1.image', '客服帮助中心二维码'); $form->image('form1.help_wechat_qrcode','客服帮助中心二维码')->default($body['help_wechat_qrcode']); $form->disableResetButton(); return "<div style='padding:10px 8px'>{$form->render()}</div>"; } protected function form2() { $form = new Form(); $form->action(request()->fullUrl()); return "<div style='padding:9px 8px'>{$form->render()}</div>"; } }
未看出问题,不过这种功能建议使用工具表单,参考 https://github.com/jqhph/dcat-admin-demo/blob/2.0/app/Admin/Forms/AdminSetting.php
Description:
v2.0.18-beta
Steps To Reproduce:
89行image字段(
form1.help_wechat_qrcode
),29行打印提交的数据(dd($data);
)结果