Reputation: 1871
I am using the new Laravel 7 Blade components. I have a new component which opens a Bootstrap delete modal like so:
<x-delete-modal
:description="$task->TaskDescription"
:id="$task->TaskID"
:route="$routeForDeleteModelModal"
:modelInstance="$task"
/>
But I am getting the following error:
Unresolvable dependency resolving [Parameter #0 [ $description ]] in class App\View\Components\DeleteModal
The component looks like this:
<!-- Delete Model Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
hello
</div>
To ensure that it wasn't the contents of the modal, I have deleted it all apart from "hello".
The DeleteModal class has 4 variables:
public $description;
public $id;
public $route;
public $modelInstance;
And it is constructed like so:
public function __construct($description, int $id, $route, $modelInstance)
{
$this->description = $description;
$this->id = $id;
$this->route = $route;
$this->modelInstance = $modelInstance;
}
I am not sure what is causing this error - I have tried making sure all my spelling is correct, reducing it down to just the description, and also doing a dd
in the constructor, but it fails before it even gets that far.
Upvotes: 3
Views: 7353
Reputation: 1871
Believe it or not, but the issue wasn't with the modal, it was with the HTML comment above it.
My comment was:
<!--
...... lots of text
Please make sure to only include '<x-delete-modal ... />' after closing a form, as this component
contains a form, and HTML does not support nested form elements.
-->
Funnily enough, including '<x-delete-modal ... />'
in the comment was causing it to fall over completely. Meaning that the comment was being compiled somehow. If anyone can explain why this happens I would really be interested in knowing.
The component works as expected when '<x-delete-modal ... />'
is removed from it.
Upvotes: 4