On 3/22/07, Jon Bennett <[EMAIL PROTECTED]> wrote:
> > this whole thread is a waste of time, as saving HABTM associations
> > using selectTags is covered in the models section of the manual!
> >
> > go to http://manual.cakephp.org/chapter/models and search for 'Saving
> > hasAndBelongsToMany Relations' (hint, towards the bottom).
>
> actually, on reading, it doesn't provide any controller code, just the
> views, hmm, so, using the view files from the example, I would do
> soemthing like:
sorry, forgot to read the value of the Post, amended:
function edit($post_id)
{
$this->Post->id = $post_id;
// nothign submitted yet
if (empty($this->data))
{
$this->data = $this->Post->read();
// get tag names/ids as key value pairs
$this->set('tags', $this->Post->Tag->generateList());
// render form
$this->render();
}
// data submitted
else
{
// no need to do anything else with the data provided
// you've followed the conventions in the view
if ($this->Post->save($this->data))
{
$this->flash('your post was saved', '/posts');
}
else
{
$this->set('data', $this->data);
$this->validateErrors($this->Post);
$this->render();
}
}
}
hth
jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---