Skip to content

[Bug] Render Create/Edit view of model with json() attribute on MariaDB #5872

@gerard-insurnet

Description

@gerard-insurnet

Bug report

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

What I did

I opened the edit view of a CRUD model which has an attribute of type json().

What I expected to happen

Render the view correctly, but instead i got the following error from the file ...\resources\views\vendor\backpack\crud\fields\textarea.blade.php:

htmlspecialchars(): Argument #1 ($string) must be of type string, array given

What happened

I have a model which migration has an attribute type json(). Running it on a MariaDB database, it's type is created as longtext. As my model has a cast for the attribute to array, and i have defined the setupUpdateOperation() function just using CRUD::setFromDb(), it's trying to render the field as textarea using as value an array from the casting.

What I've already tried to fix it

If i have my database as MySQL it works, but as MariaDB in latest versions defines the field as longText and not native json, it doesn't.

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.22

PHP EXTENSIONS:

Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, random, readline, Reflection, session, standard, mysqlnd, tokenizer, zlib, libxml, dom, PDO, opens
sl, SimpleXML, xml, xmlreader, xmlwriter, curl, fileinfo, gd, intl, mbstring, exif, mysqli, Phar, pdo_mysql, pdo_sqlite, soap, sodium, sqlite3, xsl, zip, xdebug

LARAVEL VERSION:

12.15.0.0

BACKPACK PACKAGE VERSIONS:

backpack/activity-log: 2.0.7
backpack/basset: 1.3.9
backpack/crud: 6.8.3
backpack/generators: v4.0.7
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.22
backpack/theme-tabler: 1.2.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions