Ejemplo n.º 1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
         $this->frm->getField('fname')->isFilled(BL::err('FirstNameIsRequired'));
         $this->frm->getField('lname')->isFilled(BL::err('LastNameIsRequired'));
         $this->frm->getField('address')->isFilled(BL::err('AddressIsRequired'));
         $this->frm->getField('hnumber')->isFilled(BL::err('HouseNumberIsRequired'));
         $this->frm->getField('postal')->isFilled(BL::err('PostalIsRequired'));
         $this->frm->getField('hometown')->isFilled(BL::err('HometownIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $order['id'] = $this->id;
             $order['email'] = $this->frm->getField('email')->getValue();
             $order['fname'] = $this->frm->getField('fname')->getValue();
             $order['lname'] = $this->frm->getField('lname')->getValue();
             $order['address'] = $this->frm->getField('address')->getValue();
             $order['hnumber'] = $this->frm->getField('hnumber')->getValue();
             $order['postal'] = $this->frm->getField('postal')->getValue();
             $order['hometown'] = $this->frm->getField('hometown')->getValue();
             // insert the item
             BackendCatalogModel::updateOrder($order);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_order', array('item' => $order));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('orders') . '&report=edited-order&id=' . $order['id'] . '&highlight=row-' . $order['id'] . '#tab' . ucwords($this->record['status']));
         }
     }
 }