From 12282ec570471116b9c6087c758c1df1ddf426a5 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 6 Mar 2020 18:08:25 +0100 Subject: [PATCH] fix #3468 @0.5 --- src/app/Magic/Fields/Date.php | 2 ++ src/app/Magic/Fields/Datetime.php | 2 ++ src/app/Magic/Fields/Field.php | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/Magic/Fields/Date.php b/src/app/Magic/Fields/Date.php index 0ee43a3..3105e6b 100644 --- a/src/app/Magic/Fields/Date.php +++ b/src/app/Magic/Fields/Date.php @@ -8,4 +8,6 @@ class Date extends Datetime protected $_adminType = 'date_picker'; protected $_databaseType = 'date'; protected $_cast = 'date'; + protected $_columnType = 'date'; + protected $_columnFormat = 'Y-m-d, H:i'; } diff --git a/src/app/Magic/Fields/Datetime.php b/src/app/Magic/Fields/Datetime.php index c9743f7..b20bdb6 100644 --- a/src/app/Magic/Fields/Datetime.php +++ b/src/app/Magic/Fields/Datetime.php @@ -9,6 +9,8 @@ class Datetime extends Field protected $_cast = 'datetime'; protected $pickerOptions = ['format' => 'DD/MM/YYYY HH:mm', 'language' => 'fr']; protected $_databaseType = 'datetime'; + protected $_columnType = 'datetime'; + protected $_columnFormat = 'Y-m-d, H:i'; public function _mutator($value) { diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index cdcc59f..716b256 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -15,9 +15,10 @@ class Field implements \ArrayAccess use CubistMagicAttribute; protected $_attributes; protected $_rules = []; - protected $_columnType = 'text'; + protected $_columnType = 'text'; protected $_columnMoveAfter = false; + protected $_columnFormat = null; protected $_adminType = 'text'; protected $_viewNamespace = 'crud::fields'; @@ -105,7 +106,7 @@ class Field implements \ArrayAccess return ['type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '', 'fillable' => true, 'guarded' => false, 'hidden' => false, 'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable, - 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, + 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic, 'allow_null' => true, 'can' => $this->_can, 'auth' => $this->_auth, @@ -162,6 +163,7 @@ class Field implements \ArrayAccess 'type' => $this->getAttribute('column_type'), 'label' => $this->getAttribute('column_label', $this->getAttribute('label')), 'searchLogic' => $this->getAttribute('searchLogic'), + 'format' => $this->getAttribute('column_format', null) ]; return $res; @@ -178,6 +180,9 @@ class Field implements \ArrayAccess public function defineDbColumn($table) { $name = $this->getAttribute('name'); + if ($name === 'created_at' || $name === 'updated_at') { + return; + } $table->addColumn($name, CubistMagicAbstractModel::toDoctrineType($this->getDatabaseType()), array_merge( -- 2.39.5