z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.14k stars 2.81k forks source link

[bugfix] event.value is not evaluated when the value is array #5850

Open junamai2000 opened 6 months ago

junamai2000 commented 6 months ago

The conditional form generator is not work properly when IN operator is used.

        $form->select('some_type'))
            ->rules('required')
            ->options([1, 2, 3, 4, 5])
            ->when('in', [
                1,
                2,
            ], function (Form $form) {
                $form->hasMany('xxxx', 'yyyyyy', function (Form\NestedForm $nested_form) use ($form) {
                    // do something
                })->useTable();
            });

In this case above, cascade_groups is generated like this.

var cascade_groups = [{"class":"cascade-type-312d32","operator":"in","value":["1","2"]}];

and hide class is not removed correctly because the value is not expect array.

if(default_value == event.value) {