RegistrationForm::readInputData PHP Method

readInputData() public method

Assign form data to user-submitted data.
public readInputData ( )
    function readInputData()
    {
        parent::readInputData();
        $this->readUserVars(array('username', 'password', 'password2', 'firstName', 'middleName', 'lastName', 'affiliation', 'email', 'country', 'interests', 'reviewerGroup', 'authorGroup', 'readerGroup'));
        if ($this->captchaEnabled) {
            $this->readUserVars(array('g-recaptcha-response'));
        }
        // Collect the specified user group IDs into a single piece of data
        $this->setData('userGroupIds', array_merge(array_keys((array) $this->getData('reviewerGroup')), array_keys((array) $this->getData('authorGroup')), array_keys((array) $this->getData('readerGroup'))));
    }

Usage Example

 /**
  * Validate user registration information and register new user.
  */
 function registerUser($args, &$request)
 {
     $this->validate($request);
     import('classes.user.form.RegistrationForm');
     $regForm = new RegistrationForm();
     $regForm->readInputData();
     if ($regForm->validate()) {
         $regForm->execute();
         if (Config::getVar('email', 'require_validation')) {
             // Send them home; they need to deal with the
             // registration email.
             $request->redirect(null, 'index');
         }
         $reason = null;
         Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason);
         if ($reason !== null) {
             $this->setupTemplate($request, true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('pageTitle', 'user.login');
             $templateMgr->assign('errorMsg', $reason == '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason');
             $templateMgr->assign('errorParams', array('reason' => $reason));
             $templateMgr->assign('backLink', $request->url('login'));
             $templateMgr->assign('backLinkLabel', 'user.login');
             return $templateMgr->display('common/error.tpl');
         }
         if ($source = $request->getUserVar('source')) {
             $request->redirectUrl($source);
         } else {
             $request->redirect('login');
         }
     } else {
         $this->setupTemplate($request, true);
         $regForm->display();
     }
 }
All Usage Examples Of RegistrationForm::readInputData