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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:17:10+00:00 2026-05-13T12:17:10+00:00

I have this table in my DB: Group – ID-Name – 1 -abc –

  • 0

I have this table in my DB:

Group

 - ID-Name
 - 1 -abc
 - 2 -def
 - 3 -ghi

Pages

 - id-group_id-name
 - 1 -1       -home
 - 2 -1       -about us

Now I wanted to make a select box that groups them by ‘group’ using:

function add() {

$this->set('pages', $this->Page->find('list', array('fields' => array('Page.id', 'Page.name', 'Page.group_id'))));

}

In my add.ctp:

echo $form->input('group_id', array('options' => $pages));

The output:

<select name="data[Page][id]" id="PageId">
<optgroup label="1">
<option value="1">Home</option>
<option value="2">About Us</option>
</optgroup>
</select>

I wanted the optgroup to display the actual group name not the group id like:

<select name="data[Page][id]" id="PageId">
<optgroup label="abc">
<option value="1">Home</option>
<option value="2">About Us</option>
</optgroup>
</select>

I have tried this one:

$this->Page->find('list', array('conditions' => 'Group.id = Page.id', 'fields' => array('Page.id', 'Page.name', 'Group.name')));

But ‘Group.id’ and ‘Group.name’ is unknown.

Thanks!

  • 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-13T12:17:11+00:00Added an answer on May 13, 2026 at 12:17 pm

    Try this:

    $this->Page->find('list', array(
        "fields" => array("Page.id", "Page.name", "Group.name"),
        "joins" => array(
            array(
                "table" => "groups",
                "alias" => "Group",
                "type" => "INNER",
                "conditions" => array("Group.id = Page.id")
            )
        ),
        "order" => array(...) // whatever ordering you want
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like this: name code group john 12 smith 15 how
Well I have this - Table DimDate- Date Table Employee- Id,Name,Points,Date Now the Employee
I have a database application in which a group is modeled like this: TABLE
I have a table like this one: id group value 1 GROUP A 0.641028
I have a table that looks like this Group Recipe Priority 0 A 400
I have this table Test as Id, SomeValue, SomeText contains about a mill records,
I have a stupid question, I have this table : id_product name value 1
lets say i have this table user|group|acceptance 1 | a | -1 2 |
I have an input db2 table with two elements: loan_number, debt_to_income; this table's name
I have data that looks like this: Table Group: A , Color: Blue, Count:

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.