Skip to content

Commit accae14

Browse files
committed
fix(datetimefield): fix name of the type and validity check
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 43fdbe1 commit accae14

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

inc/fields/datetimefield.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function isValid() {
9696
}
9797

9898
public static function getName() {
99-
return __('Datetime', 'formcreator');
99+
return __('Date & time', 'formcreator');
100100
}
101101

102102
public static function getPrefs() {
@@ -155,7 +155,8 @@ public function parseAnswerValues($input) {
155155
return false;
156156
}
157157

158-
if (DateTime::createFromFormat("Y-m-d H:i", $input[$key]) === false) {
158+
if ($input[$key] != ''
159+
&& DateTime::createFromFormat("Y-m-d H:i", $input[$key]) === false) {
159160
return false;
160161
}
161162

tests/suite-unit/PluginFormcreatorDatetimeField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ public function providerparseAnswerValues() {
156156
'input' => [
157157
'formcreator_field_1' => ''
158158
],
159-
'expected' => false,
160-
'expectedValue' => null,
159+
'expected' => true,
160+
'expectedValue' => ' ',
161161
],
162162
[
163163
'id' => '1',

0 commit comments

Comments
 (0)