You don't need it in the url at that point:
books_controller:
function add() {
if (!empty($this->data)) {
// Saving, whatever here
}
else {
$this->Book->create();
// List of parameters that can be specified in the url.
// Can also handle aliases (category => category_id for example)
$whitelist = array(
'category_id'
);
foreach($whitelist as $alias => $field) {
if (is_numeric($alias)) {
$alias = $field;
}
if (isset($this->params['named'][$alias])) {
$this->Book->set($field, $this->params['named'][$alias]);
}
}
$this->data = $this->Book->data;
}
}
Now in your view, make sure that you add a form field for each field,
even if it's a hidden one:
/views/books/add.ctp
echo $form->input('category_id', array('type' => 'hidden'));
This way it doesn't matter about the url. It's set once, then it's in
the form. This is also useful for default values that can be changed
by the user; it works in the same way.
hth
grigri
On Nov 14, 9:26 am, Pizgin <[EMAIL PROTECTED]> wrote:
> Hi! Address in browser "/books/add/category_id:51". If after press on
> save button except an error - CakePHP redirect me on url "/books/add"
> and "category_id:51" is missed. Can i fix it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---