protected function attach()
 {
     if (count($this->cached_att_ids) > 0) {
         return $this->cached_att_ids;
     }
     $attachment_ids = array();
     $attachment = new RM_Attachment_Service();
     $this_field_name = $this->get_field_name();
     if (!isset($_FILES[$this_field_name]) || !$_FILES[$this_field_name]) {
         return null;
     }
     $files = $_FILES[$this_field_name];
     //Check for multifile field
     if (is_array($_FILES[$this_field_name]['name'])) {
         $original_files = $_FILES;
         foreach ($files['name'] as $key => $value) {
             if ($files['name'][$key]) {
                 $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]);
                 $_FILES = array($this_field_name => $file);
                 foreach ($_FILES as $file => $array) {
                     $aid = $attachment->media_handle_attachment($file, 0);
                     if (is_wp_error($aid)) {
                         break;
                     } else {
                         $attachment_ids[$this_field_name][] = $aid;
                     }
                 }
             }
         }
         $_FILES = $original_files;
     } else {
         $aid = $attachment->media_handle_attachment($this_field_name, 0);
         if (is_wp_error($aid)) {
             return null;
         } else {
             $attachment_ids[$this_field_name] = $aid;
         }
     }
     $this->cached_att_ids = $attachment_ids;
     return $attachment_ids;
 }