Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问作者,如果想重写form应该怎么写呢? #37

Open
phpervip opened this issue Jun 23, 2020 · 1 comment
Open

请问作者,如果想重写form应该怎么写呢? #37

phpervip opened this issue Jun 23, 2020 · 1 comment

Comments

@phpervip
Copy link

在看到这个扩展前,我也是用这样的表,这么写的。注释了中文,增加了缓存。现在我想把这个继续用起来。
于是我在routes.php中增加:
// 网站配置 $router->resource('config', ConfigController::class);
但安装了此扩展后,写这句没用,并没有指向这个控制器。

` /**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new Config);
$form->display('title', '标题');
$form->display('name', '变量名');
$form->text('value', '变量值');
$form->textarea('description', '描述');
$form->display('remark', '备注');

    $form->tools(function (Form\tools $tools){
        $tools->disableView();
    });

    $form->footer(function ($footer){
        $footer->disableViewCheck();
    });

    // 表单保存后回调
    $form->saved(function (Form $form) {
        //  配置值写入缓存
        $configs = Config::get();
        foreach($configs as $val){
             $confs[$val['name']] = $val['value'];
        }
        // 每次编辑后都重新缓存
        Cache::put('web_configs',$confs);
    });
    return $form;
}`

谢谢!

@abyssgoing
Copy link

abyssgoing commented Mar 4, 2022

2020的。。。,在源文件里改。vendor_path/laravel-admin-ext/config/src/ConfigController.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants