I have a component with a form inside it. I assigned a variable to the action attribute:
<form action="{{ $action }}" method="{{ $method }}"
.
When I call the component using:
<x-component action="#" method="POST">
,
or
<x-component action="route ('my-route')" method="POST">
,
or
<x-component action="{{route ('my-route')}}" method="POST">
,
It gives me an error saying “Undefined variable $action”, and the log highlights the form tag.
The routes for that view is a controller function that does this:
$data = MyModel::all();
return view('pages.admin.dashboard', ['data' => $datab]);
I don’t know if that is relevant to the problem or not though.
What is the cause of this problem and how to solve it?
GoodGuy2213 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.