Пример #1
0
 public function preDispatch()
 {
     parent::preDispatch();
     if ($this->_hasParam('model')) {
         $this->_model = Centurion_Db::getSingletonByClassName($this->_getParam('model'));
     }
     $this->view->controller = $this->_request->getControllerName();
     $this->view->module = $this->_request->getModuleName();
     $id = $this->_getParam('id', 0);
     $form = $this->_getForm();
     if ($id > 0) {
         $action = $this->_helper->url->url(array_merge($this->_extraParam, array('controller' => $this->_request->getControllerName(), 'id' => $id, 'action' => 'put', 'module' => $this->_request->getModuleName())), null, true);
         $object = $this->_getModel()->find($id)->current();
         if (null === $object) {
             throw new Zend_Controller_Dispatcher_Exception(sprintf('Invalid action specified (%s)', $id));
         }
         if (!$form->hasInstance()) {
             $form->setInstance($object);
         }
         $form->addElement('hidden', '_method', array('value' => 'put'));
     } else {
         $action = $this->_helper->url->url(array_merge($this->_extraParam, array('controller' => $this->_request->getControllerName(), 'module' => $this->_request->getModuleName())));
         $form->removeElement('id');
     }
     $form->cleanForm();
     $form->setAction($action);
 }
Пример #2
0
 public function init()
 {
     parent::init();
     $this->getHelper('ContextAutoSwitch')->direct();
     $this->_request->setParams($this->getHelper('params')->direct());
 }