Edit composite attribute to non-composite attribute fix.

pull/61/head
noud 2012-07-04 14:05:18 +02:00
parent 8216a563dc
commit 63bdfe2961
1 changed files with 4 additions and 3 deletions

7
app/Model/Attribute.php Normal file → Executable file
View File

@ -264,14 +264,15 @@ class Attribute extends AppModel {
// or copy value to value1 if not composite type
if (!empty($this->data['Attribute']['type'])) {
$composite_types = $this->getCompositeTypes();
// explode composite types in value1 and value2
$pieces = explode('|', $this->data['Attribute']['value']);
if (in_array($this->data['Attribute']['type'], $composite_types)) {
// explode composite types in value1 and value2
$pieces = explode('|', $this->data['Attribute']['value']);
if (2 != sizeof($pieces)) throw new InternalErrorException('Composite type, but value not explodable');
$this->data['Attribute']['value1'] = $pieces[0];
$this->data['Attribute']['value2'] = $pieces[1];
} else {
$this->data['Attribute']['value1'] = $this->data['Attribute']['value'];
$this->data['Attribute']['value1'] = $pieces[0];
$this->data['Attribute']['value2'] = '';
}
}