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

  • Home
  • SEARCH
  • 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 4540978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:09:44+00:00 2026-05-21T15:09:44+00:00

I want the user to be able to choose a restaurant from a dropdown

  • 0

I want the user to be able to choose a restaurant from a dropdown list. I’m achieving this by the simple:

echo $this->Form->input(
    'Restaurant', array('multiple'=>false, array('empty' => true)));

The issue I have is: some restaurants have duplicate names, and I need a way for the user to know which is which. I’d like to have the ID and/or address within the select options like:

<li value='62'>McDonalds (1234 Happy St) - #62</li>
<li value='63'>McDonalds (9876 French Fry Ln) - #63</li>
...etc

Is there a way to do this? I’m obviously capable of doing it w/ normal HTML, but… would be nice to stay in CakePHP.

Thanks ahead of time for any thoughts/suggestions/direction!

  • 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-05-21T15:09:45+00:00Added an answer on May 21, 2026 at 3:09 pm

    When you load your restaurants you’re actually getting an array like this

    array (
      ID => NAME,
      ID => NAME
    )
    

    Basically, it’s an associated array with the ID as the key and the display field as the value. So as long as you modify that array via the find operation or via normal PHP array iteration, you can achieve your goal.

    EDIT

    So your answer is CakePHP VirtualFields

    In your model you define it as

    var $virtualFields = array(    
        'rest_unique_name' => 'CONCAT(Restaurant.first_name, " ", Restaurant.address)'
    );
    

    In your controller you do this

       $opts   = array(
                'fields'    => array('id', 'rest_unique_name')
       );
       $restaurants  = $this->Restaurant->find('list', $opts);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the user to be able to choose from a dropdown Combobox listing
In my program I want the user to be able to choose between some
I have an application where I want that the user is able to choose
I have a small question. We want the user to the able to choose
I have a form where I want the user to choose 2 different way
I'm creating a form in which user will be able to choose (among the
I want the user to be able to see the source code of the
I want the user to be able to make some preferences like colors, prefered
I want the user to be able to see my application in the menu
I want the user to be able to enter a name for a file

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.