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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:48:38+00:00 2026-06-17T14:48:38+00:00

I am currently trying to allow the users to archive events that have already

  • 0

I am currently trying to allow the users to archive events that have already been completed.

Then the event will be viewed in the Archive Table.

So basically I have one archive table, and one event table, and when the user wants to archive the event, they should be able to view the event in the archive add form (which needs to be populated by the $id of the event).

But I do not know how to populate the field.. I have tried setting a value.. but the events are not sessions so that didn’t work, and I have also tried setting the $id at the start of the form, but that also didn’t work.

Here is the code to my archive function in the events controller.

   public function archive($id = null) {
        if ($this->request->is('post')) {
            $event = $this->Event->read($id);
            $archive['Archive'] = $event['Event'];
            $archive['Archive']['eventID'] = $archive['Archive']['archiveID'];
            unset($archive['Archive']['archiveID']);
            $this->loadModel('Archive');
            $this->Archive->create();
            if ($this->Archive->save($archive)) {
                $this->Session->setFlash(__('The event has been archived'));
                $this->Event->delete($id);
                $this->redirect(array('action' => 'eventmanage'));
            } else {
                $this->Session->setFlash(__('The event could not be archived. Please, contact the administrator.'));
            }
        }
    }
  • 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-17T14:48:40+00:00Added an answer on June 17, 2026 at 2:48 pm

    You need to do one of the following:

    Set the values for the fields using $this->request->data in the controller.

    public function add($id = null) {
        if ($this->request->is('post')) {
            [..snip..]
        }
        $this->loadModel('Event');
        $event = $this->Event->read($id);
        $this->request->data['Archive'] = $event['Event'];
    }
    

    OR

    Update the form to set the values.

    Update the existing code with the same event read:

    public function add($id = null) {
        if ($this->request->is('post')) {
            [..snip..]
        }
        $this->loadModel('Event');
        $this->set('event', $this->Event->read($id));
    }
    

    Then in your form in the Archives/add.ctp file, update each input to reflect the value of the $event.

    echo $this->Form->input('eventID', array('type' => 'hidden', 'value' => $event['Event']['id']));
    

    OR

    Write a function that will move the record.

    Put a button on the Event View called ‘Archive’. Create a method in the Event Controller that will archive the event.

    public function archive($id = null) {
        if ($this->request->is('post')) {
            $event = $this->Event->read($id);
            $archive['Archive'] = $event['Event'];
            $archive['Archive']['event_id'] = $archive['Archive']['id'];
            unset($archive['Archive']['id']);
            $this->loadModel('Archive');
            $this->Archive->create();
            if ($this->Archive->save($archive)) {
                $this->Session->setFlash(__('The event has been archived'));
                $this->Event->delete($id);
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The event could not be archived. Please, contact the administrator.'));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple WYSIWYG editor that will allow users to select
I have a link that will allow users to click it and it fetches
I'm trying to allow users that have connected their Facebook accounts to my rails
I am currently trying to create a function which will allow me to pass
I am currently trying to write some code that will accept some FTP details,
I have developed a blog application of sorts that I am trying to allow
I am currently trying to make a test site that allows users to record
I'm currently trying to allow users to login with their Facebook account in my
I am trying to allow users the ability to set text they will type
I am currently making a piece of software that will allow the user to

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.