Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As Rob Wilkerson suggests, the issue is your URL route doesn't accurately describe the operation being performed. It becomes further confusing when you want to edit the reservation: <code>/reservations/edit/6</code>. Now the number in the URL means something different.</p> <p>The URL convention I use for situations like these (adapted to your particular case) is <code>/events/3/reservations/add</code>. It takes a bit more up-front to configure your routes, but I've found it's superior for clarity down the road.</p> <p>Sample <code>routes.php</code>:</p> <pre><code>Router::connect( '/events/:event_id/reservations/:action', array('controller'=&gt;'reservations','action'=&gt;'index'), array( 'pass' =&gt; array('event_id'), // pass the event_id as a param to the action 'event_id' =&gt; '[0-9]+', 'actions'=&gt;'add|index' // only reverse-routes with 'action'=&gt;'add' or // 'action'=&gt;'index' will match this route ) ) // Usage: array('controller'=&gt;'reservations','action'=&gt;'add','event_id'=&gt;3) Router::connect( '/events/:event_id/reservations/:id/:action', array('controller'=&gt;'reservations'), array( 'pass' =&gt; array('id'), // pass the reservation id as a param to the action 'id' =&gt; '[0-9]+', 'event_id' =&gt; '[0-9]+', 'actions'=&gt;'edit|delete' // only reverse-routes with 'action'=&gt;'edit' or // 'action'=&gt;'delete' will match this route ) ) // Usage: array('controller'=&gt;'reservations','action'=&gt;'edit','event_id'=&gt;3,'id'=&gt;6) </code></pre> <p>In your <code>FormHelper::create</code> call, you'd have to specify most of the reverse-route you want to follow, but again, the up-front cost will pay dividends in the future. It's usually better to be explicit with Cake than to hope its automagic always works correctly, especially as the complexity of your application increases.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload