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 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, This may be really simple or it may not even be possible, or
Okay so my question is this. Say I have a simple C++ code: #include
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay this question is very simple: I have a facebook page, and a website.
Okay, this is a pretty weird question, but the situation is this. I've got
okay so this is probably a soft pitch question for sombody, but I want
Okay, I have done a bit of searching online and found this thread, but
Okay, before you guys go nuts -- this is just a small site, temporary
Okay people, I'm sure someone has had this issue and can help me out.
Okay, none of the previous questions I have seen with this error seem 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.