Hi everyone.
Concerning the subject, the example in the manual uses a multiple
select tag, but I prefer checkboxes for usability reasons.

Is there a simple way to do that automatically, or should I going on
coding it by myself?

    function admin_add() {
      $this->layout = 'admin';
      $categories = new Category();
      $this->set('categories', $categories->findAll());
      if (!empty($this->data)) {
        if ($this->Post->save($this->data)) {
          $id = $this->Post->getLastInsertID();
          foreach ($this->data['Category'] as $k => $v) {
            if ($v == 1) {
              $this->Post->execute("INSERT INTO categories_posts SET
post_id=$id, category_id=" . $k);
            }
          }
          $this->Session->setFlash('Your post has been saved.');
          $this->redirect('/admin/posts/');
        }
      }
    }

This function that I've written works correctly, I just wanted to know
if there's something more 'agile' than this... 


Thanks in advance.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to