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 8036539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:39:10+00:00 2026-06-05T02:39:10+00:00

I have a form with only one select tag. I want to get the

  • 0

I have a form with only one select tag. I want to get the id of the selected option tag in my controller when a user submit the form. My form is

 <div class="one_third">
        <form name="portfolios" action="{{ path('MunichInnovationGroupBundle_portfolio') }}" method="post" >
            <h2>Select your portfolio</h2>
            <p>Change the portfolio to be managed:<br />
                <select name="portfolio" style="width: 265px; height:28px;">
                    <option selected="selected" value="default">Switch Your Portfolio</option>
                    {% for 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 my 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 something like this

array
 'portfolio' => string 'Umair Portfolio 1' (length=17)

Array

How can I get the id ?

Any suggestions?

Thanks in advance

  • 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-05T02:39:12+00:00Added an answer on June 5, 2026 at 2:39 am

    you must change attribute id to the value

    <option value={{ portfolio.id }}>{{ portfolio.portfolioName }}</option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdown boxes in one form - only one option can be
I have a form with a number of radiobuttons where only one should be
I have a form which has only tab control in it. I want to
I have a form with several text boxes on it. I only want to
i have DataTimePicker control in my form. i want to show only hh:mm how
I want to create a form using an unordered list ul must have only
I have a form with a select list, where the user can select anywhere
You can only have one form runat=server per page apparently. My page has one
I have some code which re-arranges some items on a form, but only one
Have a simple form (only extract fields here) but for some reason the JQserilization

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.