Skip to content

Commit 54ec553

Browse files
committed
Added support for date popup field
1 parent d1a22c7 commit 54ec553

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

os2forms.module

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,35 @@ function os2forms_theme() {
3030
],
3131
];
3232
}
33+
34+
/**
35+
* Implements hook_webform_migrate_d7_webform_element_ELEMENT_TYPE_alter().
36+
*
37+
* Not released hook
38+
* @See https://www.drupal.org/project/webform_migrate/issues/3155073
39+
*/
40+
function os2forms_webform_migrate_d7_webform_element_date_popup_alter(&$markup, $indent, array $element) {
41+
$markup .= "$indent '#type': date\n";
42+
$markup .= "$indent '#datepicker': true\n";
43+
$markup .= "$indent '#date_date_format': d/m/Y\n";
44+
45+
$extra = unserialize($element['extra']);
46+
$options = [
47+
'disabled',
48+
'readonly',
49+
'placehoder',
50+
'description',
51+
];
52+
foreach ($options as $option) {
53+
if (!empty($extra[$option])) {
54+
$value = 'true';
55+
switch ($option) {
56+
case 'description':
57+
case 'placeholder':
58+
$value = "\"" . str_replace(['"', "\n", "\r"], ["'", '\n', ''], $extra[$option]) . "\"";
59+
break;
60+
}
61+
$markup .= "$indent #$option: $value\n";
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)