jeudi 1 décembre 2016

Why is my variable undefined in my Laravel Blade when using it, but not while dumping it?

I define a Custom Form Component and a Custom Blade

Form component in a serviceprovider's boot() method

Form::component('TextInput', 'partials.inputs.text', [
        'id' => 'id-placeholder',
        'label' => 'label placeholder',
        'required' => false,
        'attr' => []
    ]);

Blade (resources\views\partials\inputs\text.blade.php)

 //"first_name"
<div class="input-field">
    <input id="" type="text"
    @if (array_key_exists('value', $attr)) value="" @endif
    @if ($required) required @endif>
    <label for="" >
        
    </label>
</div>

But with the data dump function I get the error:

Undefined variable: id (View: \resources\views\partials\inputs\text.blade.php) (View: \resources\views\partials\inputs\text.blade.php)

I call the form component from another blade with:

 

Why is this error happening, even when 2 lines above it outputs the variable?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire