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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:38:44+00:00 2026-05-26T16:38:44+00:00

Okay, so I’m fairly new to CakePHP. This is the setup: I’ve got a

  • 0

Okay, so I’m fairly new to CakePHP. This is the setup:

I’ve got a Model (Reservation), and a controller, (ReservationController).

I’m trying to provide a simple add() functionality.

The request url is: http://www.example.com/reservations/add/3

Where 3 is the ID of the event this reservation is for.
So far, so good. The problem is, the form is constructed like this:

 <h2>Add reservation</h2>
<?php echo $form->create('Reservation');
echo $form->input('first_name');
echo $form->input('last_name');
echo $form->input('email');
echo $form->input('tickets_student'); echo $form->input('tickets_nstudent');
echo $form->end('Add');?>

When I hit the send button, the request URL becomes simply http://www.example.com/reservations/add/, and the event id is lost.

I’ve solved it now by grabbing the id in the controller, and make it available to the form:

// make it available for the form
$this->set('event_id', $eventid);

And then, in the form:

$form->create('Reservation',array('url' => array($event_id)));

It works, but it strikes me as a bit ugly. Isn’t there an easier way to make sure the form POST action gets made to the current url, instead of the url without the id?

  • 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-26T16:38:44+00:00Added an answer on May 26, 2026 at 4:38 pm

    Nik’s answer will fail if the website isn’t in the server public_html root.

    This answer is more solid:

    <?php echo $form->create('Reservation',array('url'=>'/reservation/add/'.$data['id']));?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, what I'm trying to accomplish is a simple tool tip that, when you
Okay, I'm having some serious issues here. I'm new to this site, and new
Okay, so I'm running a small test webserver on my private network. I've got
Okay so im working on this php image upload system but for some reason
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay. I know this looks like the typical Why didn't he just Google it
Okay so I am trying to compare a login textbox password and username with
Okay I do not even know where to begin when it comes to this
Okay, so I have an issue with an AJAX request. I currently have this
Okay, not sure what I'm doing here, other than it's not right. Trying 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.