Replies: 1 comment
-
I had the same problem too. In my case, I have the <!-- form -->
<x-form>
<x-file name="file_a" />
<x-textarea name="textarea" is-markdown />
</x-form>
<!-- textarea -->
@props(['isMarkdown' => false])
<fieldset>
@if ($isMarkdown)
<x-file name="attachments" multiple />
@endif
<textarea></textarea>
</fieldset> For the reasons you mentioned, the properties of the first input are also assigned to the second input. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I recently noticed behavior with Laravel's blade components that I found very unintuitive. If I'm rendering a component inside another component, properties passed to the parent component are automatically passed to the child component.
Here is an example of what is happening.
top-level blade:
The confirmation form class has no constructor arguments.
confirmation-form:
Input component:
and blade:
What I expected the rendered html to look like:
But what I got instead was this:
What happens is that any component with named properties gets them filled from
$attributes
if it exists. So when we use a component inside a component, it takes the id from theComponentAttributeBag
$attributes
and passes it as a parameter to theInput
class. This behavior isn't documented anywhere.This is the code from
CompilesComponents
that does it:I think it makes no sense that it works this way, but it looks like it was done on purpose and isn't a bug? Does this make sense to anyone?
Beta Was this translation helpful? Give feedback.
All reactions