I am using Laravel 9 and trying to understand the components.
I have this 'anonymous' component (extract) :
<option value="{{ $phase->id }}" @if(isset($phase_id) && $phase_id===$phase->id) selected @endif>
{{ $phase->name }}
</option>
The component is called like that :
<x-select-phase id="phase_id" name="phase_id" :phase_id="$event->phase_id"
I am expecting that the var $phase_id
exists inside the component. It is not the case, and do not understand why. I tried a lot of things without success. What can I try next?
CodePudding user response:
https://laravel.com/docs/9.x/blade#casing
Component constructor arguments should be specified using
camelCase
, whilekebab-case
should be used when referencing the argument names in your HTML attributes.
This means:
:phase-id="$event->phase_id"
should generate a variable:
$phaseId