/**
  * Save tabs
  *
  * @param Zend\InputFilter\InputFilter $tabsSubform  Tabs sub form
  * @param DocumentType\Model           $documentType DocumentType model
  *
  * @return array
  */
 protected function saveTabs($tabsSubform, $documentType)
 {
     $existingTabs = array();
     $idx = 0;
     foreach ($tabsSubform->getValidInput() as $tabId => $tabValues) {
         if (!preg_match('~^tab(\\d+)$~', $tabId, $matches)) {
             continue;
         }
         $tabId = $matches[1];
         $tabModel = Tab\Model::fromId($tabId);
         if (empty($tabModel) or $tabModel->getDocumentTypeId() != $documentType->getId()) {
             $tabModel = new Tab\Model();
         }
         $tabModel->setDescription($tabValues->getValue('description'));
         $tabModel->setName($tabValues->getValue('name'));
         $tabModel->setDocumentTypeId($documentType->getId());
         $tabModel->setSortOrder(++$idx);
         $tabModel->save();
         $existingTabs[$tabId] = $tabModel->getId();
     }
     return $existingTabs;
 }