Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vmind_ds's avatar

Troubleshooting htmlspecialchars() error when passing closure to ViewField->viewData

I am trying to retrieve a value from an input field and pass it to ViewField->viewData, but I am encountering an error. The functionality works as expected in all other areas. Would you happen to have any suggestions?

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

Select::make('folder_name');
ViewField::make('image')->viewData([
    'path' => fn(Get $get) => $get('folder_name'),
]);
0 likes
0 replies

Please or to participate in this conversation.