]> _ Git - cubist_cms-back.git/commitdiff
#2810
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 15:01:44 +0000 (17:01 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 15:01:44 +0000 (17:01 +0200)
src/app/Magic/Fields/Field.php

index bf5e023c8a2fad1972e4bc406be9fd11244327ff..4f5e15d89525e8193d11985feb05ca465a68af87 100644 (file)
@@ -66,7 +66,9 @@ class Field
     {
         return ['type' => $this->_adminType, 'column' => false, 'form' => 'both', 'rules' => '',
             'fillable' => true, 'guarded' => false, 'hidden' => false, 'translatable' => $this->_translatable,
-            'column_type' => $this->_columnType, 'default' => '', 'cast' => $this->_cast, 'fake' => false, 'store_in' => false];
+            'column_type' => $this->_columnType, 'default' => '', 'cast' => $this->_cast,
+            'allow_null' => true,
+            'fake' => false, 'store_in' => false];
     }
 
     public function __construct($attributes)
@@ -121,7 +123,12 @@ class Field
     public function defineDbColumn($table)
     {
         $name = $this->getAttribute('name');
-        $table->addColumn($name, CubistMagicAbstractModel::toDoctrineType($this->getDatabaseType()), $this->_databaseAttributes);
+        $table->addColumn($name,
+            CubistMagicAbstractModel::toDoctrineType($this->getDatabaseType()),
+            array_merge(
+                ['allow_null' => $this->getAttribute('allow_null', true)],
+                $this->_databaseAttributes)
+        );
         if ($this->_databaseUnique) {
             $table->addUniqueIndex([$name]);
         }