Skip to content

Commit

Permalink
Issue #3512: Create special form widget for vCard email field (#3966)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-korn committed May 17, 2023
1 parent e873e93 commit bb8fadb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/json_form_widget/src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +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:');
}

return $element;
Expand Down
3 changes: 3 additions & 0 deletions modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public function flattenValues($formValues, $property, $schema) {
switch ($schema->type) {
case 'string':
$data = $this->handleStringValues($formValues, $property);
if ($property === 'hasEmail') {
$data = 'mailto:' . ltrim($data, 'mailto:');
}
break;

case 'object':
Expand Down

0 comments on commit bb8fadb

Please sign in to comment.