Problem with Input :: Old select laravel

1

I'm doing a registry, and I have a problem that when validating the selects, if an error occurs and returns to the registration page, I do not have the value when I use a ng-repeat.

This case where I have 2 options within the select if it works:

 <select name="sexo" id="sexo" class="form-control">
      <option value="" hidden>-- Seleccionar --</option>
      <option value="Hombre" 
         @if (Input::old('sexo') == 'Hombre') selected="selected" @endif>Hombre</option>
      <option value="Mujer"
         @if (Input::old('sexo') == 'Mujer') selected="selected" @endif>Mujer</option>
  </select>

But when I have many values it does not work for me as in this case, which is to select the birthday day:

 <select name="dia" id="dia" class="form-control">   
     <option value="" hidden="">Día</option>
     <option ng-repeat="dia in listaDias" 
       value="<%dia.dia%>" 
       {{ (Input::old('dia') == '<%dia.dia%>' ? "selected" : "") }} ><%dia.dia%></option>
 </select> 

If I take out the single quotes to '<%dia.dia%>' , I get an error. If I put Input::old('dia') == 3 (say some number, leave the last number that would be 31).

If there is no solution with the ng-repeat , I accept other ways to load the 31 numbers of that select.

    
asked by Juan Pablo B 24.10.2016 в 22:30
source

1 answer

1

I could solve it by doing the following in the html view:

  @for($i=1; $i<=31;$i++)
    <option  value="{{$i}}"
      {{ (Input::old('dia') == $i ? "selected" : "") }}>{{$i}}</option>
  @endfor
    
answered by 24.10.2016 в 23:55