Skip to content

Commit

Permalink
Replace ltrim with str_replace in json_form_widget (#4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
janette committed Jan 2, 2024
1 parent f1cd384 commit 2f9b794
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/json_form_widget/src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function handleStringElement($definition, $data, $object_schema = FALSE)
// Add extra validate if element type is email.
if ($element['#type'] === 'email') {
$element['#element_validate'][] = [$this, 'validateEmail'];
$element['#default_value'] = ltrim($element['#default_value'] ?? '', 'mailto:');
$element['#default_value'] = str_replace('mailto:', '', $element['#default_value']);
}

return $element;
Expand Down
2 changes: 1 addition & 1 deletion modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function flattenValues($formValues, $property, $schema) {
case 'string':
$data = $this->handleStringValues($formValues, $property);
if ($property === 'hasEmail' && is_string($data)) {
$data = 'mailto:' . ltrim($data, 'mailto:');
$data = 'mailto:' . str_replace('mailto:', '', $data);
}
break;

Expand Down

0 comments on commit 2f9b794

Please sign in to comment.