コード例 #1
0
 public function editsignupAction()
 {
     $con = $this->_getConvention();
     $form = ConventionSignup::getForm($con);
     $id = (int) $this->getParam('id');
     $record = ConventionSignup::find($id);
     if ($record instanceof ConventionSignup) {
         $form->setDefaults($record->toArray(TRUE, TRUE));
     } else {
         throw new \DF\Exception\DisplayOnly('Cannot create new signup records from this page.');
     }
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         $record->fromArray($data);
         $record->save();
         $this->alert('Changes saved.', 'green');
         $this->redirectFromHere(array('action' => 'signups', 'convention' => $con->id, 'id' => NULL));
         return;
     }
     $this->renderForm($form, 'edit', 'Edit Signup Record');
 }
コード例 #2
0
 public function editsignupAction()
 {
     $this->acl->checkPermission('is logged in');
     $con = $this->_getConvention(TRUE);
     $user = $this->auth->getLoggedInUser();
     if (!$con instanceof Convention) {
         throw new \DF\Exception\DisplayOnly('Convention not found!');
     }
     if (!$con->canSignup()) {
         throw new \DF\Exception\DisplayOnly('You cannot add or update a signup record for this convention.');
     }
     // Retrieve auto-customized form for this convention.
     $form = ConventionSignup::getForm($con);
     $record = ConventionSignup::getRepository()->findOneBy(array('convention_id' => $con->id, 'user_id' => $user->id));
     if ($record instanceof ConventionSignup) {
         $form->setDefaults($record->toArray());
     } else {
         $form->setDefaults($user->toArray());
     }
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         if (!$record instanceof ConventionSignup) {
             $record = new ConventionSignup();
             $record->convention = $con;
             $record->user = $user;
         }
         $record->fromArray($data);
         $record->save();
         // Save some data to the user profile.
         $user->fromArray(array('legal_name' => $data['legal_name'], 'pony_name' => $data['pony_name'], 'phone' => $data['phone'], 'pvl_affiliation' => $data['pvl_affiliation']));
         $user->save();
         $this->alert('<b>Convention registration successfully submitted.</b><br>You will be contacted by the PVL administrators with more information.', 'green');
         $this->redirectFromHere(array('action' => 'signup', 'id' => NULL));
         return;
     }
     $this->view->setVar('title', 'Convention Signup Form');
     $this->renderForm($form);
 }