示例#1
0
 public function executeEdithome()
 {
     $this->setscope();
     $this->form = new sfBreadNavEditHomeForm();
     //if not post populate and show form.
     //if post validate and save.  redirect to admin.
     if ($this->getRequest()->isMethod('post')) {
         $values = $this->getRequest()->getParameter('sfbreadnavedithomeform');
         $this->form->bind($values);
         if ($this->form->isValid()) {
             if (sfBreadNavPeer::saveHome($values, $this->scope)) {
                 $this->redirect('sfBreadNavAdmin/index?scope=' . $this->scope);
             } else {
                 $this->setTemplate('breadnav');
                 $this->message = "You need to be logged in to save a root page.";
                 return sfView::ERROR;
             }
         }
     } else {
         $root = sfBreadNavPeer::getRoot($this->scope);
         if ($root) {
             //populate form
             $this->form->bind($root->toForm());
         } else {
             //invalid scope id
             if ($this->scope = null) {
                 $this->setTemplate('breadnav');
                 $this->message = "You need to be logged in to create a root page.";
                 return sfView::ERROR;
             }
         }
     }
 }