Reputation: 1
Need variable php in blade laravel - value input, variable $i to for add the value of $i, within the value = "{ {$ tarefa->etapa. $i }}
to do so: value = "{{ $tarefa->etapa1 }} value = "{{ $tarefa->etapa2 }} ... to 10
@php
$now = 0;
$last = 10; @endphp
@for ($i = $now; $i < $last; $i++)
<div class="col-sm-6">
<input id="etapa" class="form-syle" name="etapa1" value="{{ $tarefa->etapa**@variable php** }} ">
</div>
@endfor
Upvotes: 0
Views: 45
Reputation: 1325
You can put the name of the attribute you need into a string.
$attributeName = 'etapa'.$i;
<input id="etapa" class="form-syle" name="etapa1" value="{{ $tarefa->$attributeName }} ">
Upvotes: 1