예제 #1
0
파일: Device.php 프로젝트: vitaliy5118/ss1
 public function __construct(Application_Form_Devices $form)
 {
     if ($form->getValue('id') != NULL) {
         $this->id = $form->getValue('id');
     }
     $this->number = $form->getValue('number');
     $this->name = $form->getValue('name');
     $this->type = $form->getValue('type');
     $this->owner = $form->getValue('owner');
     $this->user = $form->getValue('user');
     $this->status = $form->getValue('status');
     $this->city = $form->getValue('city');
     $this->adress = $form->getValue('adress');
     $this->tt_name = $form->getValue('tt_name');
     $this->tt_user = $form->getValue('tt_user');
     $this->tt_phone = $form->getValue('tt_phone');
 }
예제 #2
0
 public function editAction()
 {
     // action body
     $form = new Application_Form_Devices();
     $form->submit->setLabel('Редактировать');
     $_SESSION['edit'] = true;
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             //Успешная валидация
             //Извлекаем данные в обьект
             $device = new Application_Model_Device($form);
             //Редактируем данные в базе
             $device->edit();
             $this->_helper->redirector('index');
         } else {
             //Неуспешная валидация
             //Возвращаем данные в таблицу
             $form->populate($formData);
         }
     } else {
         $id = $this->getParam('id');
         $device = new Application_Model_DbTable_Devices();
         $form->populate($device->getDevice($id));
     }
 }