question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty name for subfields not handling properly

See original GitHub issue

Bug report

What I did

I was using a select2 to populate the read-only fields in the form in v4.1 To quickly trick the CRUD ignore this nested field, i set the field to be empty name. In v5, it is not properly handled…

                'name'  => 'jobs',
                'label' => 'Jobs',
                'type'  => 'relationship',
                'subfields' => [
                    [
                        'name'             => '',
                        'label'            => "Dummy Select",
                        'type'             => 'select2_from_array',
                        'options'          => $this->options,
                        'allows_multiple'  => false,
                        'wrapper'          => ['class' => 'form-group col-md-3 dummy-select2'],
                    ],

What I expected to happen

Understand that it is documented as name is a mandatory attribute. However, an empty string is not considered as undefined name. I need the proper way to skip this field. https://backpackforlaravel.com/docs/5.x/upgrade-guide#step-15 Maybe a meaningful Exception should be thrown to tell name cannot be empty string?

What happened

With Empty Name image

With Name image

So, it breaks when trying to save

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'jobs[-1' in 'field list'

What I’ve already tried to fix it

N/A

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:

PHP 8.0.16 (cli) (built: Feb 21 2022 14:42:00) ( NTS ) Copyright © The PHP Group Zend Engine v4.0.16, Copyright © Zend Technologies with Zend OPcache v8.0.16, Copyright ©, by Zend Technologies

LARAVEL VERSION:

v8.83.2@b91b3b5b39fbbdc763746f5714e08d50a4dd7857

BACKPACK VERSION:

5.0.9@d995de2026b6fcb1b13b469f371c929c29d1c1cc

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
pxpmcommented, Mar 15, 2022

I’ve sent #4268 to address this.

Thanks again @kiddtang !

Best, Pedro

1reaction
tabacitucommented, Mar 8, 2022

I am asking to handle the empty name field in a better way…

I TOTALLY agree with that. Just talked to Pedro about this yesterday… that we should throw an error with a clear message. If an empty name in a field triggers an error… then an empty name in a subfield should trigger an error too.

During the journey of the v5 upgrade, I encounter many exceptions

Please open issues when you find other confusing errors like this. It’s something we want from Backpack v5, to be a lot easier to debug. The more clear errors messages we throw, the faster developers can know what to do, instead of searching or scratching their heads.

Read more comments on GitHub >

github_iconTop Results From Across the Web

100 Main Entry--Personal Name (NR) - OCLC
100 Main Entry--Personal Name (NR) ; 3, Family name ; 2nd Indicator Undefined ; blank character, Undefined ; Subfields (R=Repeatable NR= ...
Read more >
Understanding MARC Bibliographic: Parts 7 to 10
When an indicator is undefined, the character position will be represented by the character # (for blank space). Subfield codes -- All the...
Read more >
Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or ... restaurant name or location can't be null //...
Read more >
Configuring Normalization Rules for Display and Local Fields
# This rule checks for the existence of a 502 field and makes sure that subfields a and b and c are not...
Read more >
Field Masks - Ads API - Google Developers
When updating a MESSAGE field that is not defined with any subfields, ... Creates a campaign with the proper resource name and an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found