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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:34:13+00:00 2026-06-03T20:34:13+00:00

CakePHP has the default of unique set to true, I’ve coded it just to

  • 0

CakePHP has the default of unique set to true, I’ve coded it just to make sure as well.
So I have the following DB structure:
Item HABTM Action, with unique set to true.

The situation is as followed:

Deletion works fine upon save when I delete 1 or more records, if ATLEAST 1 record stays ‘alive’

Deletion doesn’t work upon save when I delete all records ( or 1 record, if that’s the only one). It simply keeps all existing records that way.

I’ve made sure with debug($this->request->data) right before save that it contained Nothing of Action.

  • 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-03T20:34:15+00:00Added an answer on June 3, 2026 at 8:34 pm

    From the discussion in the comments on your post I am still confused, but what I understand is that you’re trying to:
    Save a POST in a format similar to this:
    array(
    ‘Item’ => array(
    ‘id’ => ‘3’
    )
    With:

     $this->Item->SaveAll($this->request->data);
    

    Your POST should contain a ‘Action’ key:

    array(
        'Item' => array(
            'id' => '3'
        ),
        'Action' => array(
            'Action' => array()
        )
    

    When the “Action” key is set, Cake knows that it has to go “over” the relation and to it’s magic.
    Then it will delete.

    I just tested this on a App that I’m developing and actually found it to be a bug. 😀 The problem
    was that for the specific HATBM relation I had to use manually generated forms and thus when posting with nothing included the relation key was not set and the records, weren’t deleted. I suppose that the Form Helper deals with this.

    If you have a similar problem you can manage this in two different manners:

    1. Put a hidden input with JavaScript

    2. In the Controller check if the ‘Action’ key is set, and if not add it (as an empty array):

      $this->request->data[‘Action’][‘Action’] = array();

      This may be kind of intrusive, but It’ll do the job.

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

Sidebar

Related Questions

I have a simple cakephp app with table articles that has a cat_id column
Cakephp is giving me some problems as I have set as below (I have
I have a single model in CakePHP that has multiple forms on different pages
I have a CakePHP model - User - that has ties to an external
I have a Cakephp project the controller has several different methods. function Index() function
I have a cakephp object (SecurityPerson) that has a few foreign key relationships to
I have set up REST for my CakePHP and I'm having a slight problem.
I have table 'pages' in my database. I have noticed that cakePHp has a
I have a site (built on LAMP (cakephp) and has ssl certificate installed) which
I have already put nusoap folder in cakephp vendor folder ../vendor/nusoap/lib/nusoap.php (it has more

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.