Skip to content

Textarea field ignores displayUsing value #5886

@Sjoertjuh

Description

@Sjoertjuh
  • Laravel Version: 10.21.0
  • Nova Version: 4.27.12
  • PHP Version: 8.2.0
  • Database Driver & Version: mysql-8.0
  • Operating System and Version: windows 11
  • Browser type and version: chrome 116.0.5845.187

Description:

When using the Textarea field, the value displayed is not using the value provided by displayUsing.
I believe this is because the internal resolveForDisplay is not checking if usesCustomizedDisplay is set and using displayedAs when it is.
Because the value I'm using, it cannot be displayed normally, so an error is thrown and the page cannot be loaded.

Maybe relevant traces:

htmlspecialchars(): Argument #1 ($string) must be of type string, array given {"userId":1,"exception":"[object] (TypeError(code: 0): htmlspecialchars(): Argument #1 ($string) must be of type string, array given at /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:124)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php(124): htmlspecialchars(Array, 11, 'UTF-8', true)
#1 /var/www/html/vendor/laravel/nova/src/Fields/Textarea.php(62): e(Array)
#2 /var/www/html/vendor/laravel/nova/src/Fields/FieldCollection.php(120): Laravel\\Nova\\Fields\\Textarea->resolveForDisplay(Object(App\\Models\\Pitches\\Script))

Detailed steps to reproduce the issue on a fresh Nova installation:

  1. Create a model that has a column of a type not supported by Textarea (JSON in my case)
  2. Use the displayUsing function to change the display value to something that is supported by Textarea (in my case a string)
  3. Watch the error htmlspecialchars(): Argument #1 ($string) must be of type string, array given {"userId":1,"exception":"[object] (TypeError(code: 0): htmlspecialchars(): Argument #1 ($string) must be of type string, array given at /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:124) appear

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions