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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:03:37+00:00 2026-05-21T10:03:37+00:00

Question Overview: I want to be able to edit an item (a restaurant in

  • 0

Question Overview:

I want to be able to edit an item (a restaurant in this case) and allow the user to select multiple options (cuisines) that use a table of connections to access a list of the options/cuisines.

Question Details:

I have 3 tables:

restaurants:          id, name, address, phone...etc
cuisines:             id, name, url_name
cuisine_connections:  id, restaurant_id, cuisine_id

As you can imagine, the cuisine_connections table is a list of connections between the cuisines, and the restaurants. (If anyone has a better solution for this I’m all ears).

model/restaurant.php:

    var $hasMany = array(
    'CuisineConnection' => array(
        'className' => 'CuisineConnection',
        'foreignKey' => 'restaurant_id',
        'dependent' => false
    )
);

model/cuisine.php

    var $hasMany = array(
    'CuisineConnection' => array(
        'className' => 'CuisineConnection',
        'foreignKey' => 'cuisine_id'
    )
);

model/cuisine_connection.php

var $belongsTo = array(
    'Cuisine' => array(
        'className' => 'Cuisine',
        'foreignKey' => 'restaurant_id',
        'dependent' => false
    ),
    'Restaurant' => array(
        'className' => 'Restaurant',
        'foreignKey' => 'restaurant_id'
    )
);

I’ve tried this so far:

controllers/restaurants_controller.php:

$this->set('cuisines', $this->Restaurant->CuisineConnection->Cuisine->find('list'));

admin_add.ctp:

echo $this->Form->input('cuisine_id', array('multiple'=>'checkbox'));
  • 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-21T10:03:38+00:00Added an answer on May 21, 2026 at 10:03 am

    You could read this tutorial for undestand clearly about implementing many-to-many association in CakePhp. Beside that, the line code:

    $this->set('cuisines', $this->Restaurant->CuisineConnection->Cuisine->find('list'));
    

    has problems. I think that, depend on your description, you should list all the Cuisine for choosing with coresponding restaurant. The code should be replaced by:

    $this->set('cuisines', $this->Cuisine->find('all'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to make this overview of questions and the user has to be
My question here is why should i want use the entity framework instead of
The quick overview is this: for my web app I can write most of
This is actually a pretty simple question but I can't seem to find the
This might be a rather big question to just answer shortly; much kudos for
I have a question regarding FLWOR joins. Here's an overview of how my XMLs
General Overview: The function below spits out a random ID. I'm using this to
I want to create something similar to: http://www.atlassian.com/software/jira/overview (See the URLs changing on click
I have a new question for WCF gurus. So, I have a class User
[This blog post titled: ' Passing multiple Include statements into a Repository ' provides

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.