public function actionUpdateRegion()
 {
     /**
      * check if the user is already logged in
      * if so, do nothing and return them to the home screen
      */
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new UpdateRegionForm();
     $stateList = State::find()->all();
     $countyList = County::find()->orderBy('name')->all();
     if ($model->load(Yii::$app->request->post())) {
         $subHead = 'You must select a region.';
         if ($model->validate()) {
             $subHead = 'Region Successfully Changed';
             $post = Yii::$app->db->createCommand()->delete('access', ['user_id' => Yii::$app->user->getId()])->execute();
             foreach ($model->access as $county => $id) {
                 if ($id != "multiselect-all") {
                     $post = Yii::$app->db->createCommand()->insert('access', ['county_id' => $id, 'user_id' => Yii::$app->user->getId()])->execute();
                 }
             }
         }
         $access = Access::findAll(['user_id' => Yii::$app->user->getId()]);
         $access = ArrayHelper::getColumn($access, 'county_id');
         return $this->render('update-region', ['access' => $access, 'model' => $model, 'stateList' => $stateList, 'countyList' => $countyList, 'subHead' => $subHead]);
     }
     $access = Access::findAll(['user_id' => Yii::$app->user->getId()]);
     $access = ArrayHelper::getColumn($access, 'county_id');
     return $this->render('update-region', ['access' => $access, 'model' => $model, 'stateList' => $stateList, 'countyList' => $countyList, 'subHead' => '']);
 }
 /**
  * actionRegister
  *
  * the Register action contains most of the logic behind user registration.
  * When it is called it checks to see if any data can be loaded into the
  * RegistrationForm model. If not then that means the user has not yet been
  * taken to the registration page, so it collects the data need to render
  * the registration page/form (all of the states and counties needed to fill
  * in the dropdowns, etc.) and renders view/site/registration. If however
  * data is able to be loaded into the RegistrationForm model, then that
  * means that the user has already submitted a filled out form, so it calls
  * model->validate() to make sure that all of the input is good and to make
  * sure that the entered username and email address have not already been
  * taken. If that does not return any errors then newUser(), a member
  * function of SiteController, is called and the RegistrationForm model is
  * passed in. After that, registration-confirm is rendered.
  */
 public function actionRegister()
 {
     /**
      * check if the user is already logged in
      * if so, do nothing and return them to the home screen
      */
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     /** 
      * loads model that will store all data entered into the ActiveForm
      * on register.php and contains all front-end validation rules
      */
     $model = new RegistrationForm();
     /* Used to populate 'select state' dropdown and 'select region' section */
     $stateList = State::find()->all();
     /* Used to populate the 'select region' multiselects */
     $countyList = County::find()->orderBy('name')->all();
     /**
      * if the user has made a 'post' request AND registration form model
      * is able to succesfully register the user based on the inputted information 
      */
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         /* Calls member function newUser() and passes in a populated model */
         $this->newUser($model);
         /* registration was successful, go back to registration-confirm view */
         return $this->render('registration-confirm', ['model' => $model]);
     } else {
         /**
          * The user has not yet been taken to the registration form so
          * render the registration view and pass in an empty RegistrationForm
          * model that is stored in $model
          */
         return $this->render('register', ['model' => $model, 'stateList' => $stateList, 'countyList' => $countyList]);
     }
 }