Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for datetime-local #1532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/yform/value/datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class rex_yform_value_datetime extends rex_yform_value_abstract
public function preValidateAction(): void
{
$value = $this->getValue();

if ('' == $this->getValue() && $this->params['main_id'] < 1) {
if (1 == $this->getElement('current_date')) {
$value = date(rex_sql::FORMAT_DATETIME);
Expand All @@ -36,7 +37,11 @@ public function preValidateAction(): void
$second = (int) ($value['second'] ?? 0);
} else {
$value = (string) $value;
$value = explode(' ', $value);
$localTimeTest = explode(' ', $value);
if (2 != count($localTimeTest)) {
$localTimeTest = explode('T', $value);
}
$value = $localTimeTest;
if (2 == count($value)) {
$date = explode('-', (string) $value[0]);
$year = (int) ($date[0] ?? 0);
Expand Down Expand Up @@ -64,7 +69,11 @@ public function enterObject()
$second = (int) ($value['second'] ?? 0);
} else {
$value = (string) $value;
$value = explode(' ', $value);
$localTimeTest = explode(' ', $value);
if (2 != count($localTimeTest)) {
$localTimeTest = explode('T', $value);
}
$value = $localTimeTest;
if (2 == count($value)) {
$date = explode('-', (string) $value[0]);
$year = (int) ($date[0] ?? 0);
Expand Down Expand Up @@ -182,7 +191,8 @@ public static function getSearchField($params)
'name' => $params['field']->getName(),
'label' => $params['field']->getLabel(),
'notice' => rex_i18n::msg('yform_values_date_search_notice', $format),
'attributes' => '{"data-yform-tools-datetimerangepicker":"' . $format . '"}', ]);
'attributes' => '{"data-yform-tools-datetimerangepicker":"' . $format . '"}',
]);
}

public static function getSearchFilter($params)
Expand Down
Loading