Reassign $view_mode using entity field passed to hook_entity_view_mode_alter() I'm using baseFieldDefinitions to create my custom entity form.
With gracious help here, I've been able to successfully generate a radio button on the form which lets the user select what view mode to use for the display.

Goal: 
Get the selected value from the radio button on the form and use it to reset the view mode for the display.

Problem:
Other than my general confusion, I believe I have a cache issue when invoking the hook to alter the view mode.  I'd like to think I was finally able to overcome the array value to single value assignment problems.

I added this code into MY-MODULE.module:

/**  * Implements hook_entity_view_mode_alter().  */
function nfl_entity_view_mode_alter(&amp;$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
    // Change the view mode to the value selected via radio button on the form.

    if ($entity-&gt;getEntityTypeId() == 'nfl_fact'  ) {  /*&lt;-- restrict to custom entity */

        $change_to_view_mode = $entity-&gt;change_view-&gt;value;  /*&lt;-- get the lowercase value -- not Initial Cap Label  */

        drupal_set_message(sprintf('&lt;pre&gt; change_to_view_mode %s&lt;/pre&gt;', print_r($change_to_view_mode, TRUE))); 
        drupal_set_message(sprintf('&lt;pre&gt; view_mode before %s&lt;/pre&gt;', print_r($view_mode, TRUE))); 

        //  $view_mode = $change_to_view_mode;  /*&lt;--- reassign view mode here -didn't work*/
        $entity-&gt;view_mode[LANGUAGE_NONE][0]['value'] = $val[0]-&gt;change_to_view_mode;  /* &lt;-- reassign */
        $entity-&gt;save();

        drupal_set_message(sprintf('&lt;pre&gt; view_mode after reassignment %s&lt;/pre&gt;', print_r($view_mode, TRUE))); 
    }
}


I added some drupal_set_message entries to reassure myself that I was getting the variable values changed.

&lt;pre&gt; change_to_view_mode standard&lt;/pre&gt;
&lt;pre&gt; view_mode before full&lt;/pre&gt;
&lt;pre&gt; view_mode after reassignment standard&lt;/pre&gt;
Cache cleared.


When I click on my link from the viewlist builder, I don't get the display.  I get White Screen of Death with the error in the PHP log:

(first few lines)

[29-Sep-2018 02:15:53 UTC] TypeError: Argument 1 passed to Drupal\Core\Form\OptGroup::flattenOptions() must be of the type array, null given,
    called in C:\wamp\www\drupal8\web\core\modules\options\src\Plugin\Field\FieldFormatter\OptionsDefaultFormatter.php on line 40
    in C:\wamp\www\drupal8\web\core\lib\Drupal\Core\Form\OptGroup.php on line 23
#0 C:\wamp\www\drupal8\web\core\modules\options\src\Plugin\Field\FieldFormatter\OptionsDefaultFormatter.php(40): Drupal\Core\Form\OptGroup::flattenOptions(NULL)
#1 C:\wamp\www\drupal8\web\core\lib\Drupal\Core\Field\FormatterBase.php(80): Drupal\options\Plugin\Field\FieldFormatter\OptionsDefaultFormatter-&gt;v


I'm confused.
Also am open to guidance on how to better format this question if it looks too goofy ;)
I'm not sure exactly what's going on here, but looking at the documentation for hook_view_mode_alter, it looks like you're not resetting the view mode properly. It looks like you need to set it like:

/**
 * Implements hook_entity_view_mode_alter().        
 */
function nfl_entity_view_mode_alter(&amp;$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
  // Change the view mode to the value selected via radio button on the form.
  if ($entity-&gt;getEntityTypeId() == 'nfl_fact' ) {
    $view_mode = $entity-&gt;change_view-&gt;value;
  }
}