Skip to content

Commit

Permalink
Issue #3023005 by heshanlk: Error converting to YAML when there are s…
Browse files Browse the repository at this point in the history
…pecial characters
  • Loading branch information
heshanmw authored and Heshan Wanigasooriya committed Dec 29, 2018
1 parent f6b1508 commit d640ad5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Plugin/migrate/source/d7/D7Webform.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ private function buildFormElements($nid) {
$option = explode('|', $item);
$valid_options[] = $option[0];
if (count($option) == 2) {
$options .= "$indent$ingroup " . $option[0] . ": " . $option[1] . "\n";
$options .= "$indent$ingroup " . $option[0] . ": '" . str_replace('\'', '"', $option[1]) . "'\n";
}
else {
$options .= "$indent$ingroup " . $option[0] . ": " . $option[0] . "\n";
$options .= "$indent$ingroup " . $option[0] . ": '" . str_replace('\'', '"', $option[0]) . "'\n";
}
}
}
Expand Down Expand Up @@ -459,8 +459,8 @@ private function buildFormElements($nid) {
}

// Add common fields.
if (!empty($element['value']) && (empty($valid_options) || in_array($element['value'], $valid_options))) {
$markup .= "$indent '#default_value': " . $element['value'] . "\n";
if (!empty(trim($element['value'])) && (empty($valid_options) || in_array($element['value'], $valid_options))) {
$markup .= "$indent '#default_value': '" . str_replace(array('\'', "\n", "\r"), array('"', '\n', ''), trim($element['value'])) . "' \n";
}
if (!empty($extra['field_prefix'])) {
$markup .= "$indent '#field_prefix': " . $extra['field_prefix'] . "\n";
Expand All @@ -476,7 +476,7 @@ private function buildFormElements($nid) {
$markup .= "$indent '#title_display': " . $title_display . "\n";
}
if ($element['type'] != 'pagebreak') {
$markup .= "$indent '#title': " . $element['name'] . "\n";
$markup .= "$indent '#title': '" . str_replace('\'', '"', $element['name']) . "' \n";
$markup .= "$indent '#description': \"" . $description . "\"\n";
}
if (!empty($element['required'])) {
Expand Down

0 comments on commit d640ad5

Please sign in to comment.