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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:22:22+00:00 2026-06-18T08:22:22+00:00

I’m having trouble working out where I went wrong in my function and I

  • 0

I’m having trouble working out where I went wrong in my function and I would like to know if there was anyway for me to find out where the function breaks either using net beans or whilst I’m executing the function.

If you would like to see the function then here’s a copy of it:

             public function archive($id = null) {
    if ($this->request->is('post')) {
        $event =  $this->Event->read(null, $id);
        $archive['Archive'] = $event['Event'];
        $archive['Archive']['archiveID'] = $event['Event']['eventID'];
        unset($archive['Archive']['archiveID']);
        $this->loadModel('Archive');
        $this->Archive->create();
        if ($this->Archive->save($archive)) {
           // $this->Archive->invalidFields();
            $this->redirect(array('action' => 'eventmanage'));
            $this->Session->setFlash(__('The event has been archived'));
          //  $this->Event->delete($id);  
        } else {
            $this->redirect(array('action' => 'eventmanage'));
            $this->Session->setFlash(__('The event could not be archived, Please, contact the administrator.'));
        }
    }
}

so far i have tried using the `$errors = $this->Archive->validationErrors;` function but all i receive back is the word 'array' 

UPDATE

I have got the event to save as an archive, however it does not send the message $this->Session->setFlash(__('The event has been archived')); And it does not redirect back to eventmanage, it creates a new link to the /Controller/Action/id e.g. /events/archive/14 .

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-06-18T08:22:23+00:00Added an answer on June 18, 2026 at 8:22 am

    The validationErrors property returns an array. You can’t echo an array object in PHP, as it’s a collection of data, rather than something that can “just” be output to your screen. There are other functions to display the full array though, like var_dump(), print_r() or the CakePHP methods debug() or Debugger::dump(). So try something like this:

    $errors = $this->Archive->validationErrors;
    if (!empty($errors)) { debug($errors); }
    

    You can also use implode() to output all the validation errors as a string in your flash message, for example:

    $this->Session->setFlash(__('The event could not be archived, because of the following errors: ' . implode('<br/>', $errors) . '. Please, contact the administrator.'));
    

    That will display all the errors, separated with a break within the flash message.

    Update
    In regard to your latest question update, the flash message is not set, because you redirect before you set it. So, the statement is never reached. Swap the setFlash and redirect methods in your controller, so you’ll get:

    $this->Session->setFlash(__('The event has been archived'));
    $this->redirect(array('action' => 'eventmanage'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.