function doSave($data, $form)
 {
     $new_record = $this->record->ID == 0;
     if ($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) {
         $template = Subsite::get()->byID(intval($data['TemplateID']));
         if ($template) {
             $this->record = $template->duplicate();
         }
     }
     return parent::doSave($data, $form);
 }
 /**
  * @param $data
  * @param $form
  * @return HTMLText|SS_HTTPResponse|ViewableData_Customised|void
  */
 public function doSave($data, $form)
 {
     $currentStage = Versioned::current_stage();
     Versioned::reading_stage('Stage');
     $action = parent::doSave($data, $form);
     Versioned::reading_stage($currentStage);
     if ($this->record->isPublished()) {
         $this->publish($data, $form);
     }
     return $action;
 }
 public function doSave($data, $form)
 {
     if ($this->record->ID == 0 && $this->component instanceof LRGridFieldDetailForm && $this->component->getItemLimit() > 0 && $this->gridField->getList()->count() + 1 > $this->component->getItemLimit()) {
         $form->sessionMessage(_t('LimitedRelationsGridField.ITEM_LIMIT_REACHED', '_You cannot add any more items, you can only add {count} items. Please remove one then try again.', array('count' => $this->component->getItemLimit())), 'bad');
         $responseNegotiator = new PjaxResponseNegotiator(array('CurrentForm' => function () use(&$form) {
             return $form->forTemplate();
         }, 'default' => function () use(&$controller) {
             return $controller->redirectBack();
         }));
         $controller = Controller::curr();
         if ($controller->getRequest()->isAjax()) {
             $controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
         }
         return $responseNegotiator->respond($controller->getRequest());
     }
     return parent::doSave($data, $form);
 }