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

HuTu's avatar
Level 4

Blade component attributes merge and curly brackets

This is my first post on this forum, despite my 6 yr membership, so hello everyone!

But to the point. Does anyone tries to merge Alpines x-data attribute using ComponentAttributeBag:merge() method? Like this:

<x-form.field {{ $attributes->merge([
    'x-data' => '{type: \'password\', value: \'test\'}',
]) }}>

It seems, that the Blade compiler fails on this, because there are curly brackets inside the attribute value. Am I doing something wrong? I came up with a workaround, but it's ugly and I don't like it.

<x-form.field {{ $attributes->merge([
    'x-data' => html_entity_decode('&#123;type: \'password\', value: \'\'&#125;'),
]) }}>

Is there a better way to do this? Or is this a bug?

0 likes
0 replies

Please or to participate in this conversation.