0

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?

1 Answer 1

2

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}}

Sign up to request clarification or add additional context in comments.

1 Comment

If that has provided a solution to you please accept it as an answer by clicking the checkmark.

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.