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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:11:41+00:00 2026-05-31T18:11:41+00:00

I am wondering how I would go about performing a certain function if a

  • 0

I am wondering how I would go about performing a certain function if a particular field in cakephp save has been updated.

function edit($id = null) {
    if (!empty($this->data)) {
        if ($this->Post->save($this->data)) {
                $this->Session->setFlash(__('The post has been saved', true));
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The post could not be saved. Please, try again.', true));
        }
    }
}

So – what I would like to do is be able to determine exactly what has been changed in the edit data ($this->data) and if a certain field has been changed send an email notification. I know how to do the email part – but can’t figure out how I would do it if lets say a select box was changed from Enabled to Disabled. If changed from enabled to disabled email saying blah blah blah has been disabled.

  • 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-31T18:11:43+00:00Added an answer on May 31, 2026 at 6:11 pm

    You can read out the current saved content before you execute $this->Post->save() and compare the values after saving.

    if (!empty($this->data)) {
    
      $oldValue=$this->Post->field('yourfield');
    
      if ($this->Post->save($this->data)) {
        if ($oldValue!=$this->data['Post']['yourfield'])
        {
          // do stuff
        }
        ...
    

    As mark said, it would be cleaner to acomplish this direct in the model (e.g. in the case the data is changed in a different form)

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

Sidebar

Related Questions

I've been wondering about how hard it would be to write some Python code
Just wondering how you would go about implementing something similar to stackoverflow'd related questions.
I'm wondering how you would go about designing a good permgen space string in
I'm wondering how i would go about making the following application: a user signs
I was wondering, how would you go about writing an application that basically houses
I'm wondering what good ways there would be make assertions about synchronization or something
I was wondering how would go about displaying five images in a row using
Just wondering how you would go about creating the effect as seen in the
I am wondering how I would go about correctly setting up a C++/CLI library
I was just wondering how you would go about giving a application the new

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.