Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.08k stars 887 forks source link

Editable select (editable_select) bug or there is no option for allow null ? #5380

Closed AdamovicBoban closed 5 months ago

AdamovicBoban commented 10 months ago

I'm trying to set up an editable select in listOperation to accept null, but it's not working. I've tried allow_null, default, and hint, but none of these are working. Is this a bug, or is there no option for allowing null?

    CRUD::addColumn([
            'name'    => 'driver_id',
            'label'   => 'Driver',
            'type'    => 'editable_select',
      //      'placeholder' => "Select user",
      //      'default' => null,
      //      'allow_null' => true,
            'options' => (function ($entry) {
                return \App\Models\User::drivers()->pluck('first_name', 'id')->toArray();
        }),
            'underlined'       => true,
            'save_on_focusout' => true,
            'save_on_change'   => true,
            'on_error' => [
                'text_color'          => '#df4759',
                'text_color_duration' => 0,
                'text_value_undo'     => false,
            ],
            'on_success' => [
                'text_color'          => '#42ba96',
                'text_color_duration' => 3000,
            ],
            'auto_update_row' => true,
        ]);
### PHP VERSION:
PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:15) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.12, Copyright (c), by Zend Technologies
    with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

### LARAVEL VERSION:
10.33.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.2.2
backpack/crud: 6.3.0
backpack/devtools: 3.0.2
backpack/editable-columns: 3.0.2
backpack/generators: v4.0.2
backpack/permissionmanager: 7.1.1
backpack/pro: 2.0.18
backpack/settings: 3.1.0
backpack/theme-coreuiv2: 1.2.2
backpack/theme-coreuiv4: 1.1.1
backpack/theme-tabler: 1.1.1
welcome[bot] commented 10 months ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

pxpm commented 9 months ago

Hey, @AdamovicBoban this is on my plate.

I just haven't got the time to get to it yet. Sorry 😞

During this week I will get back here and try to figure out what's happening.

Thanks for the report, and sorry for the delay.

Cheers

AdamovicBoban commented 8 months ago

Hey, @AdamovicBoban this is on my plate.

I just haven't got the time to get to it yet. Sorry 😞

During this week I will get back here and try to figure out what's happening.

Thanks for the report, and sorry for the delay.

Cheers

Hey @pxpm Which week? or year? 😏

pxpm commented 8 months ago

Hey @AdamovicBoban sorry again, thanks for the ping.

There is no built in functionality for a placeholder/null option, but you can just add it yourself as an option:

        'options' => (function ($entry) {
                return array_merge(['' => 'Select an option'],\App\Models\User::drivers()->pluck('first_name', 'id')->toArray());
        }),

Hope it helps. 🙏