php - Get the id of selected option of select tag in symfony2 controller -
i have form 1 select tag. want id of selected option tag in controller when user submit form. form is
<div class="one_third"> <form name="portfolios" action="{{ path('munichinnovationgroupbundle_portfolio') }}" method="post" > <h2>select portfolio</h2> <p>change portfolio managed:<br /> <select name="portfolio" style="width: 265px; height:28px;"> <option selected="selected" value="default">switch portfolio</option> {% portfolio in portfolios %} <option id={{ portfolio.id }}>{{ portfolio.portfolioname }}</option> {% endfor %} </select> </p> <p> <input style="margin-left:100px; height:26px; cursor:pointer; background-color: #2d9ad3 !important; border: 1px solid #067ebd; color: #ffffff; text-shadow: 0 -1px 0 #067ebd;" type="submit"class="button2 tooltip" value="switch"> </p> </form> </div> in controller
if($request->getmethod() == 'post'){ $data = $request->request->all(); //$portfolio_id = $data['portfolio_id']; var_dump($data); echo $data; exit(); } the var_dump($data) gives me this
array 'portfolio' => string 'umair portfolio 1' (length=17) array how can id ?
any suggestions?
thanks in advance
you must change attribute id value
<option value={{ portfolio.id }}>{{ portfolio.portfolioname }}</option>
Comments
Post a Comment