Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:41+00:00 2026-06-09T12:34:41+00:00

Hey I am trying to get the selected option value in my route (annotation).

  • 0

Hey I am trying to get the selected option value in my route (annotation). I have Portfolio Controller which contains Index view. Inside the index view there is a form with only one select drop down. Initially the URL looks like

http://localhost/idp/web/app_dev.php/portfolio/ 

The form inside the index view is

<form name="portfolios" action="{{ path('v2_pm_portfolio_switch') }}" method="post" >
    <select name="portfolio" style="width: 200px; height:25px;">
        <option selected="selected" value="default">Switch Your Portfolio</option>
        {% for portfolio in portfolios %}
            <option value={{ portfolio.id }}>{{ portfolio.portfolioName }}</option>
        {% endfor %}
    </select>
   <input type="submit"class="portfolio_input button2 tooltip" value="Switch">
</form>

When the user submit the form, it calls the switchportfolio Action (inside portfolio controller)
My switch portfolio Action is

/**
* Switch Portfolio action.
* @Route("/{user selected option name should come here}", name="v2_pm_portfolio_switch")
* @Secure(roles="ROLE_Normal_Registered_User")
* @Template("MunichInnovationGroupPatentBundle:Portfolio:index.html.twig")
*/
public function switchportfolioAction(Request $request){
    }

How can I send the selected option name to my URL in Symfony2 ?
So that, if the user select portofolio1, and submit the form the URL becomes :

http://localhost/idp/web/app_dev.php/portfolio/portfolio1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:34:42+00:00Added an answer on June 9, 2026 at 12:34 pm

    Do something like this:

    /**
     * Switch Portfolio action.
     * @Route("/v2_pm_portfolio_switch", name="v2_pm_portfolio_switch")
     * ...
     */
    public function switchPortfolioAction(Request $request){
        //check that the form parameters are OK and get the portfolio id from the request
        return $this->redirect($this->generateUrl('show_portfolio',array('portfolio'=>$portfolioId)));                
    
    }
    
    /**
     * Show Portfolio action.
     * @Route("/portfolio/{portfolio)", name="show_portfolio")
     * ...
     */
    public function showPortfolioAction($portfolio){
        //do whatever you need to show this portfolio
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys. I am trying to get the selected option in an each loop.
Hey all, i have a problem with trying to get 2 forms to close
Hey all i am trying to get the value from this code: <DIV id=lcm_simlive_countdown>00
Hey i'm trying to get the side with which the two objects in the
Hey everyone I'm trying to get a clearer understanding of LINQ. I have a
Hey all I'm trying to get a window populated with a table view that
Hey guys...I am trying to get some data based on a condition which I
Hey im trying to get a List working, in that case i have a
Hey there, I am trying to get my signout button to work. This is
Hey, im trying to get an INSERT command to work, but I keep getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.