Skip to content

[Bug] Undefined array key in select2 field #1281

@dluccajose

Description

@dluccajose

Bug report

Please note: All issues must be submitted in English. If not, they will be closed automatically.

What I did

Used a relationship field (for a belongsTo relationship), filter the options using the 'options' key of the field like this

[
      'name' => 'executive_id',
      'label' => __('Executive'),
      'type' => 'relationship',
      'options' => function ($query) {
          return $query->executives();
      },
      'wrapper' => ['class' => 'form-group col-md-6'],
  ],

What I expected to happen

When i edit a record that their current value for the field executive_id is no longer available (because of the filter), it should displays empty

What happened

It thows an "Undefined array key x" error

What I've already tried to fix it

Modify the select.blade.php inside the relationship folder to check for the value first, this work but i think it should be something that is fixed in the package

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.2.26

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, ast, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, intl, exif, msgpack, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, shmop, SimpleXML, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, redis, Zend OPcache

### LARAVEL VERSION:
10.48.22.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.41
backpack/generators: v4.0.7
backpack/permissionmanager: 7.2.1
backpack/pro: 2.1.13
backpack/settings: 3.1.1
backpack/theme-coreuiv4: 1.1.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions