Laravel-admin: 使用Admin下面的form组件,rules无效

Created on 13 Mar 2017  ·  1Comment  ·  Source: z-song/laravel-admin

public function create()
    {
        return Admin::content(function (Content $content) {

            $content->header('header');
            $content->description('description');

            $content->body($this->form());
        });
    }

protected function form()
    {
        return Admin::form(RingManage::class,function (Form $form) {
            $form->tab('Basic', function (Form $form) {

                $form->display('id');
                $form->text('name')->rules('required');
                $form->email('email')->rules('required');
                $form->display('created_at');
                $form->display('updated_at');

            })->tab('Profile', function (Form $form) {

                $form->url('profile.homepage');
                $form->ip('profile.last_login_ip');
                $form->datetime('profile.last_login_at');
                $form->color('profile.color')->default('#c48c20');
                $form->mobile('profile.mobile')->default(13524120142);
                $form->date('profile.birthday');

//                $form->map('profile.lat', 'profile.lng', 'Position')->useTencentMap();
                $form->slider('profile.age', 'Age')->options(['max' => 50, 'min' => 20, 'step' => 1, 'postfix' => 'years old']);
                $form->datetimeRange('profile.created_at', 'profile.updated_at', 'Time line');

            })->tab('Sns info', function (Form $form) {

                $form->text('sns.qq');
                $form->text('sns.wechat');
                $form->text('sns.weibo');
                $form->text('sns.github');
                $form->text('sns.google');
                $form->text('sns.facebook');
                $form->text('sns.twitter');
                $form->display('sns.created_at');
                $form->display('sns.updated_at');

            })->tab('Password', function (Form $form) {

                $form->password('password')->rules('confirmed');
                $form->password('password_confirmation');

            });

            $form->ignore(['password_confirmation']);
        });
    }

提交的时候 rules始终没有反应,是还缺少什么判断代码吗?

>All comments

原因找到了,是因为我的路由没有用resource来接收

$router->resource('/ring/test', ExampleController::class);
$router->get('/ring/test', 'ExampleController@index');
Was this page helpful?
0 / 5 - 0 ratings

Related issues

amun1303 picture amun1303  ·  3Comments

xiaalngf picture xiaalngf  ·  3Comments

abufalbo picture abufalbo  ·  3Comments

qcol picture qcol  ·  3Comments

joernroeder picture joernroeder  ·  3Comments