0

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
2
  • Could you share some more snippets of code, and try to explain your problem more elaborately. Commented Jul 16, 2020 at 23:27
  • add the value of $i, within the value = "{ {$ tarefa->etapa. $i }} to do so: value = "{{ $tarefa->etapa1 }} value = "{{ $tarefa->etapa2 }} ... to 10 Commented Jul 16, 2020 at 23:30

1 Answer 1

1

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 }}  ">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.