BUG Fix php schema generation

This commit is contained in:
Christopher Joe 2016-11-02 19:30:41 +13:00
parent 67f00302f9
commit 0901de2995
3 changed files with 8 additions and 9 deletions

View File

@ -114,7 +114,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumb
private static $db = array( private static $db = array(
"Name" => "Varchar(255)", "Name" => "Varchar(255)",
"Title" => "Varchar(255)", "Title" => "Varchar(255)",
"File" =>"DBFile", "File" => "DBFile",
// Only applies to files, doesn't inherit for folder // Only applies to files, doesn't inherit for folder
'ShowInSearch' => 'Boolean(1)', 'ShowInSearch' => 'Boolean(1)',
); );

View File

@ -1412,9 +1412,7 @@ class FormField extends RequestHandler {
* @todo Add deep merging of arrays like `data` and `attributes`. * @todo Add deep merging of arrays like `data` and `attributes`.
*/ */
public function setSchemaData($schemaData = []) { public function setSchemaData($schemaData = []) {
$current = $this->getSchemaData(); $this->schemaData = array_merge($this->schemaData, $schemaData);
$this->schemaData = array_merge($current, array_intersect_key($schemaData, $current));
return $this; return $this;
} }
@ -1424,7 +1422,8 @@ class FormField extends RequestHandler {
* @return array * @return array
*/ */
public function getSchemaData() { public function getSchemaData() {
return array_replace_recursive($this->getSchemaDataDefaults(), $this->schemaData); $defaults = $this->getSchemaDataDefaults();
return array_replace_recursive($defaults, array_intersect_key($this->schemaData, $defaults));
} }
/** /**
@ -1477,9 +1476,7 @@ class FormField extends RequestHandler {
* @todo Add deep merging of arrays like `data` and `attributes`. * @todo Add deep merging of arrays like `data` and `attributes`.
*/ */
public function setSchemaState($schemaState = []) { public function setSchemaState($schemaState = []) {
$current = $this->getSchemaState(); $this->schemaState = array_merge($this->schemaState, array_intersect_key($schemaState, $this->schemaState));
$this->schemaState = array_merge($current, array_intersect_key($schemaState, $current));
return $this; return $this;
} }
@ -1489,7 +1486,8 @@ class FormField extends RequestHandler {
* @return array * @return array
*/ */
public function getSchemaState() { public function getSchemaState() {
return array_merge($this->getSchemaStateDefaults(), $this->schemaState); $defaults = $this->getSchemaStateDefaults();
return array_merge($defaults, array_intersect_key($this->schemaState, $defaults));
} }
/** /**

View File

@ -399,6 +399,7 @@ class ChangeSet extends DataObject {
if ($this->isInDB()) { if ($this->isInDB()) {
$fields->addFieldToTab('Root.Main', ReadonlyField::create('State', $this->fieldLabel('State'))); $fields->addFieldToTab('Root.Main', ReadonlyField::create('State', $this->fieldLabel('State')));
} }
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);
return $fields; return $fields;
} }