diff --git a/lib/Drupal/views/ViewStorageController.php b/lib/Drupal/views/ViewStorageController.php index ef5911aa09d97d5dbc225d7f0100102771bcf059..f297b075c4e3c88f4cffc8ab8c3f9d77838ad7b7 100644 --- a/lib/Drupal/views/ViewStorageController.php +++ b/lib/Drupal/views/ViewStorageController.php @@ -104,7 +104,17 @@ public function save(StorableInterface $entity) { * Overrides Drupal\config\ConfigStorageController::create(). */ public function create(array $values) { + + // If there is no information about displays available add at least the + // default display. + $values += array( + 'display' => array( + 'default' => array() + ) + ); + $entity = parent::create($values); + $this->attachDisplays($entity); return $entity; } diff --git a/views.module b/views.module index 5d13a6317894b6fe12fe828a4007b2aaf26c893e..e17fa825fd29fc55b335fa137780c71fe7770c21 100644 --- a/views.module +++ b/views.module @@ -1507,9 +1507,7 @@ function views_get_all_templates() { * it can be successfully saved. */ function views_new_view() { - $view = new View(); - $view->vid = 'new'; - $view->add_display('default'); + $view = entity_create('view', array()); return $view; }