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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:30:10+00:00 2026-05-22T19:30:10+00:00

i am using cakephp 1.3 to generate a form i am creating a select

  • 0

i am using cakephp 1.3 to generate a form i am creating a select list using hasOne and belongsTo relation

my models: image, category

category hasMany image

image belongsTo Category

category table has two columns id and category_name

i am doing

$this->set('categories', 
           $this->Image->Category->find(
                                        'list',
                                         array( 'order' => 'category_name ASC' )
                                       )
          ); //to generate the select list

so far so good, there is only one problem left, the select list generated shows the id of the category instead of the category_name as the option text, i know this is not cakePHP’s fault but i need to know the solution

any help please.

P.S if i am unclear about the question please let me know

  • 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-22T19:30:11+00:00Added an answer on May 22, 2026 at 7:30 pm

    You need to define the displayField property in your category model, so that CakePHP can properly determine which field to display as a label. This code in your category model will fix it for you:

    var $displayField = 'category_name';
    

    Alternatively, rename the category_name field to ‘name’ or ‘title’ (I would do this, it’s obvious that a ‘name’ field in a category table is going to be the name of the category).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using CakePHP's form helper to generate a checkbox is easy enough; to use the
Using CakePHP (On PHP 5.2.6) I do a list query on a table which
I'm trying to create an XML sitemap using CakePHP, from a table which has
To avoid reinventing the wheel, I am generating a form using CakePHP's form helper,
I have two models, Post hasMany Comment . How do I select all Post
Using CakePHP 1.2, I am trying produce a GROUP BY query: SELECT `categories`.*, COUNT(`entities`.id)
Using cakephp, I have a generic address table, which I want to link to
I have the following code to generate some spans using cakephp's helper <div id=numberRow>
Using CakePHP 1.3 we have a booking system for hotel rooms. A check-availability form
I am using cakephp containable to retrieve related models $this->Order->find('first', array( 'conditions'=>$conditions, 'contain' =>

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.