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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:17:11+00:00 2026-06-04T21:17:11+00:00

This might be considered too non-specific a question, but I’m sure others have come

  • 0

This might be considered too non-specific a question, but I’m sure others have come up against this kind of conundrum, so it might just warrant being asked!

I have two models: Users and Surveys. My goal is to edit/save records from the Index view. In the Index view, each User row will have two select lists and some checkboxes. The select lists are populated with the names of all the available Surveys.

The purpose is to allow an admin to assign two Surveys to each user; to edit and save the records, right from the Index view. Currently, associations take place via a hasMany Through association: the intermediary model is called SurveyAssignments (I can’t do HABTM because I’m storing meta info).

What I’m struggling with is this: I can’t figure out how to save all those associations from the view. What’s making it tricky is the fact that each user will have a different association “state”: some users will have association records, some will not. Some will need associations created, others updated or removed. New users will be added to the system, but will still appear in the list with currently existing users, who already have associations.

There’s also an issue with constraint: each user will only ever have a maximum of two SurveyAssignment records associated with them.

Again, it’s the logic that I can’t wrap my head around: how can I save multiple records from one view, accounting for each User’s unique association states, all without getting overly bloated or complex? Are there any Cake methods I’m missing that could simplify the situation?

  • 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-04T21:17:12+00:00Added an answer on June 4, 2026 at 9:17 pm

    The main issue I was having was trying to save edits AND new records simultaneously. As it turns out, Cake’s automagic can take care of this.

    When you run a saveMany or saveAll, if you don’t include an ID for a record, it creates a new record. If you do include an ID, Cake updates the pre-existing record.

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

Sidebar

Related Questions

This might seem like a very easy question for some of you folks, but
This might be a simple question but I've searched and searched and can't find
This might be a very basic question but it confuses me. Can two different
This might sound like a stupid question but just trying to learn something here.
This might have to be broken down a bit but what i want to
This might be a general mvp places and activities question, but the show case
This might sound rudimentary but, I have created tables by running queries in Workbench
This might be a doozy of a question or I might be asking too
I might be being a bit thicky here but please answer me this. Consider
This might be a naive question. However, I am just trying to understand why

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.