Skip to content

Commit

Permalink
Fix: allow creation of empty fields (legacy storage would fail)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaetano Giunta committed Feb 23, 2017
1 parent 7b02510 commit 6b014a6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions eZ/Publish/FieldType/Option/OptionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ private function serializeData(FieldValue $value)

$xml = new \SimpleXMLElement('<ezoption/>');
$xmlName = $xml->addChild('name');
$this->appendCData($xmlName, $data['name']);
$this->appendCData($xmlName, isset($data['name']) ? $data['name'] : '');

$xmlOptions = $xml->addChild('options');

if (isset($data['options'])) {
/** @var OptionElement[] $options */
$options = $data['options'];
foreach ($options as $option) {
/** @noinspection DisconnectedForeachInstructionInspection */
$xmlOption = $xmlOptions->addChild('option');
$this->appendCData($xmlOption, $option['text']);
$xmlOption->addAttribute('additional_price', $option['additional_price']);
$xmlOption->addAttribute('id', $option['id']);
$options = $data['options'];
foreach ($options as $option) {
/** @noinspection DisconnectedForeachInstructionInspection */
$xmlOption = $xmlOptions->addChild('option');
$this->appendCData($xmlOption, $option['text']);
$xmlOption->addAttribute('additional_price', $option['additional_price']);
$xmlOption->addAttribute('id', $option['id']);
}
}

return $xml->asXML();
Expand Down

0 comments on commit 6b014a6

Please sign in to comment.