Crud: [Bug] - When DB column is named 'file', upload field breaks.

Created on 2 Jun 2020  路  1Comment  路  Source: Laravel-Backpack/CRUD

Bug report

When DB column is named file (_which is pretty usual_), upload field breaks.
This is a Backpack 4.1 bug. Previous versions were working fine.

What I did

My db column is named file. Wanted to add an upload field for this db column.

What I expected to happen

Work as usual.

What happened

Turns out that if a db column is named 'file', in the file wrapper_start.blade.php, there is a check if the attribute is a callback or a string.

When it does this check, it calls the php function: is_callable().
The problem is that file, which is the attribute name, is also a php native function.

This makes backpack think that this is a callback and not a string and tries to call the php function file().

What I've already tried to fix it

The problem is under the file wrapper_start.blade.php. Cannot solve without a PR.

Backpack, Laravel, PHP, DB version

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

### PHP VERSION:
PHP 7.4.5 (cli) (built: Apr 23 2020 02:25:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies

### LARAVEL VERSION:
v7.13.0@6fa69bfbd57744a5bbec5538ce483919b3fd625f

### BACKPACK VERSION:
4.1.6@cbd4143d3eb8302916012af205565cd3183f274f
Bug

Most helpful comment

Hello @robertotcestari

This is already fixed. #2862

Best,

>All comments

Hello @robertotcestari

This is already fixed. #2862

Best,

Was this page helpful?
0 / 5 - 0 ratings