private function preSaveSection(SectionModel $section) { if ($section->type != 'single' && !$section->id) { $sectionRecord = new SectionRecord(); // Shared attributes $sectionRecord->name = $section->name; $sectionRecord->handle = $section->handle; $sectionRecord->type = $section->type; $sectionRecord->enableVersioning = $section->enableVersioning; if (!$sectionRecord->save()) { $section->addErrors(['errors' => $sectionRecord->getErrors()]); return false; } $section->id = $sectionRecord->id; return true; } return Craft::app()->sections->saveSection($section); }