samedi 2 avril 2016

SOLVED: How to use old() of laravel if the name of the input is a object

I am trying to return the values from the controller but I am having a hard time how to repopulate the inputs. The name of the inputs is object. name="" depends on the id of the product.

@foreach ($products as $product)
    <li class="list-group-item pa10">
    <div class="row">
        <label for="" class="col-xs-7 pt5">{{ $product->nickname }}</label>
        <div class="col-xs-5 pl0">
                <input type="number" name="products[{{ $product->id }}]" class="form-control input-sm" min="0" data-val="1" value="{{ old(" ????? ") }}">
            </div>
        </div>
  </li>
@endforeach

I already tried old("products[$product->id]"), $index = "products[$product->id]"; echo old($index);

UPDATE:

If ever someone encounter this kind of error, i found a solution

old("products.$product->id").



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire