Skip to content

[Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. #5549

Open
@dimkys

Description

@dimkys

Bug report

What I did

I added a repeatable field with an image subfield.
The image has parameters: 'withFiles' => [ 'disk' => 'public', 'path' => 'registration-steps',],

When creating everything works fine, but when updating there is a problem.

CRUD::addField([
            'name' => 'images',
            'label' => 'Images',
            'type' => 'repeatable',
            'subfields' => [
                [
                    'name' => 'image',
                    'type' => 'image',
                    'label' => 'Image',
                    'withFiles' => [
                        'disk' => 'public',
                        'path' => 'registration-steps',
                    ],
                    'wrapper' => ['class' => 'form-group col-md-4'],
                ],

            ],
            'min_rows' => 0,
            'reorder' => true,
        ]);

What I expected to happen

After creation. I change the data (associated with inages) and save. The data has changed and everything is fine.
And this json data not changed "[{\"image\":\"registration-steps\\\/7AASbQ8QU8QaUR9dRJOj82rNUaKnbINpzomGCYtu.jpeg\"},{\"image\":\"registration-steps\\\/4fb9ggIdOL6FCAVA7buJQ8q4zkA2VFy8iJtnXobT.png\"}]"

What happened

Data in field images broken, file deleted from disk and in db images = "[{\"image\":\"7AASbQ8QU8QaUR9dRJOj82rNUaKnbINpzomGCYtu.jpeg\"},{\"image\":\"4fb9ggIdOL6FCAVA7buJQ8q4zkA2VFy8iJtnXobT.png\"}]".

What I've already tried to fix it

So far the fix is ​​to not use 'path' in 'withFiles'

Is it a bug in the latest version of Backpack?

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

Backpack, Laravel, PHP, DB version

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

PHP VERSION:

8.1.28

PHP EXTENSIONS:

Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, readline, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, xml, wddx, xmlreader, xmlwriter, mbstring, igbinary, openssl, sockets, Phar, curl, enchant, exif, fileinfo, ftp, gd, gettext, imagick, intl, mysqli, odbc, pdo_mysql, pdo_pgsql, pdo_sqlite, soap, sqlite3, timezonedb, xmlrpc, xsl

LARAVEL VERSION:

10.48.7.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.1
backpack/crud: 6.7.15
backpack/devtools: 2.0.3
backpack/editable-columns: 3.0.9
backpack/filemanager: 3.0.4
backpack/generators: v4.0.2
backpack/langfilemanager: 5.0.0
backpack/logmanager: v5.0.1
backpack/permissionmanager: 7.0.1
backpack/pro: 2.2.0
backpack/settings: 3.1.0
backpack/theme-tabler: 1.1.1

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions