/**
  * This function is called after an EntityForm is submitted. Iterate over
  * $termNames variable and see which ones have taxonomy terms. These taxonomy
  * terms are created during form submission. Add these to global $entities
  * object so that they can be deleted later.
  *
  * @param Form $formObject
  *   Form object.
  * @param string $field_name
  *   Field name.
  *
  * @return array
  *   An array with 2 values:
  *   (1) $success: TRUE.
  *   (2) $msg: An empty string.
  */
 public static function processAfterSubmit(Form $formObject, $field_name)
 {
     if (self::isCckField($formObject, $field_name)) {
         $field_info = Field::getFieldInfo($field_name);
         $vocabulary = $field_info['settings']['allowed_values'][0]['vocabulary'];
         $class = "RedTest\\entities\\TaxonomyTerm\\" . Utils::makeTitleCase($vocabulary);
         if (sizeof(self::$termNames)) {
             global $entities;
             foreach (self::$termNames as $termName) {
                 $terms = taxonomy_get_term_by_name($termName, $vocabulary);
                 foreach ($terms as $tid => $term) {
                     // We are assuming that there will be only one term with the same
                     // name in a given vocabulary.
                     $entities['taxonomy_term'][$tid] = new $class($tid);
                     unset(self::$termNames[$termName]);
                 }
             }
         }
     }
     return new Response(TRUE, NULL, "");
 }