Skip to content

Commit

Permalink
fix(datefield): change event and comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Nov 5, 2022
1 parent a959839 commit 9da9477
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions inc/field/datefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public function equals($value): bool {
$answer = $this->value;
}
$answerDatetime = DateTime::createFromFormat(self::DATE_FORMAT, $answer);
$answerDatetime->setTime(0,0,0,0);
$compareDatetime = DateTime::createFromFormat(self::DATE_FORMAT, $value);
$compareDatetime->setTime(0,0,0,0);
return $answerDatetime == $compareDatetime;
}

Expand All @@ -162,7 +164,9 @@ public function greaterThan($value): bool {
$answer = $this->value;
}
$answerDatetime = DateTime::createFromFormat(self::DATE_FORMAT, $answer);
$answerDatetime->setTime(0,0,0,0);
$compareDatetime = DateTime::createFromFormat(self::DATE_FORMAT, $value);
$compareDatetime->setTime(0,0,0,0);
return $answerDatetime > $compareDatetime;
}

Expand Down
5 changes: 1 addition & 4 deletions js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1673,13 +1673,10 @@ function pluginFormcreatorInitializeCheckboxes(fieldName, rand) {
* Initialize a date field
*/
function pluginFormcreatorInitializeDate(fieldName, rand) {
var field = $('[name="_' + fieldName + '"]');
var field = $('[name="' + fieldName + '"]');
field.on("change", function() {
plugin_formcreator.showFields($(field[0].form));
});
$('#resetdate' + rand).on("click", function() {
plugin_formcreator.showFields($(field[0].form));
});
}

/**
Expand Down

0 comments on commit 9da9477

Please sign in to comment.