Reputation: 299
i am new in laravel, i have a dropdown list and i want to populate it with years from 'UserController' i dont want to write a long list of year, i just want years to be added on every year change.
in my controller
public function setYear(){
$op="";
for($i=2010;$i<date('Y')+1;$i++)
{
$op.="<option value=".$i.">".$i."</option></br>";
}
return View::make('admin.setYear')->with('options',$op);
}
in my view
<select name="gender">
<option>Select</option>
{{$op}}
</select>
i get this Undefined variable: op (View
how can i do this?
Upvotes: 0
Views: 527
Reputation:
Your variable name is options
, not $op
.
The name you pass in the with()
the first parameter is what you use to access it in the view.
Switch {{$op}}
to {{$options}}
Upvotes: 2