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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:03:52+00:00 2026-06-16T21:03:52+00:00

quick best-practices question(s). I have as association as follows: User hasOne UserBasicInfo UserBasicInfo has

  • 0

quick best-practices question(s).

I have as association as follows:
User hasOne UserBasicInfo
UserBasicInfo has a select element for country (in which the user is living).
The select element is populated by a simple ‘countries’ table (id, country name, abbreviation)

Is it best to use Model::query() for getting the data from the countries table? Or should I create a model for this data?

If creating a model, should I use an association with the UserBasicInfo model, Or should I just use the $uses variable?

If it sways the answer, there are actually many select fields populated in a similar fashion.

  • 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-16T21:03:54+00:00Added an answer on June 16, 2026 at 9:03 pm

    If it sways the answer, there are actually many select fields populated in a similar fashion.

    It might. Do you have multiple Country select boxes, or are these select fields all pulling from different tables? If the former, you can use the options key in FormHelper::select() to populate multiple selects from one array:

    Controller:

    $this->loadModel('Country');
    $this->set('countries', $this->Country->find('list'));
    

    View:

    $this->Form->select('UserBillingInfo.country_id', $countries);
    $this->Form->select('UserShippingInfo.country_id', $countries);
    etc...
    

    Otherwise, I typically handle this situation by creating the proper associations between my models, and then using either Model::find('list') or a custom Model method to retrieve the options. If you name your variables properly, the options variable will automatically be used as the options for your select:

    Controller:

    $this->set('countries', $this->User->UserBasicInfo->Country->find('list'));
    

    View:

    $this->Form->input('UserBasicInfo.country_id');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question on best practices. I have one project MVC3 + razor that on
I just have a quick best practice question regarding custom cells in a UITableView.
Quick question on best practice. I have an AJAX application where there are 4
I just have a quick question to see what the best practice would be
I have a quick question on best practice and if getters and setters are
I have a quick question that I hope has a quick and clear answer.
Just a quick question: What are people's practices when you have to define the
A quick question about best practice with PHP classes. I have seen people use
I have a quick question - is there a best practice in SQL Table
A quick question on best practice for handling images in a PHP/MySQL CMS. Each

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.