CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

[Bug] Backpack does not guess attributes in ```subfields```

Open susanu opened this issue 1 year ago • 1 comments
trafficstars

Bug report

Backpack does not guess the column attributes for subfields. Create a HasMany relationship and try to display it like in the example below.

CRUD::column('articles')->type('relationship')->subfields([['name' => 'category_id']]);
Undefined array key "type"

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

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

### PHP VERSION:
8.3.9

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

### LARAVEL VERSION:
11.20.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.5
backpack/crud: 6.7.26
backpack/filemanager: 3.0.8
backpack/pagemanager: 3.3.0
backpack/permissionmanager: 7.2.1
backpack/pro: 2.1.7
backpack/theme-tabler: 1.2.11

susanu avatar Aug 14 '24 08:08 susanu

Hey @susanu indeed there is an inconsistency here that we should probably address, but i've already spent quite some time today trying to make this work, and it doesn't have a simple solution.

Inferring the attributes is not the biggest issue, but it breaks other parts of the functionality like the linkTo() macros for example. And it may be a breaking change also in other places I am not aware now.

I will postpone working on this on the next major version so that we can confidently introduce this, even with unknown breaking changes that we can document/fix when discovered.

For now, we need to keep manually adding the attributes to subfields in the columns.

Cheers

pxpm avatar Aug 14 '24 14:08 pxpm