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

Custom datetime field in custom content type can not be saved #5444

Closed
Kontsept opened this issue Aug 20, 2019 · 3 comments · Fixed by #5451
Closed

Custom datetime field in custom content type can not be saved #5444

Kontsept opened this issue Aug 20, 2019 · 3 comments · Fixed by #5451

Comments

@Kontsept
Copy link

Issue Overview

A new content of a newly created custom content type cannot be saved because of a datetime field not saved correctly. This issue happens on a german Wordpress with only the "Twenty Seventeen" Theme and the PODS Plugin activated.

Expected Behavior

I want to save a custom datetime field in a custom content type.
A click on the datetime field should open a datetime picker to choose date and time.
I should be able to choose a time between 00:00 and 23:59 (german time system) and save the value to the content.

Current Behavior

Choosing a date with the datetime picker is not a problem. But there is an issue when choosing a time. The datetime picker lets me choose a time from "12:00vorm." to "11:00nachm.".
When I choose one of these times (e.g. 05:00nachm. which corresponds to 05:00pm) and I save the content, all the custom fields are emptied and none is saved.

Steps to Reproduce (for bugs)

  1. Install Wordpress in German
  2. Install the PODS-Plugin
  3. Create a custom content type with a custom datetime field
  4. Create a new content of the newly created content type
  5. Choose a date and time using the datetime picker
  6. Save the content

Possible Solution

Option 1: Change the datetime picker for German sites to select times betweeen 00:00 and 23:59. When I manually change the field text from "05:00nachm." to "17:00" the content can be saved.
Option 2: When the datetime picker passes the value to the field it could be rewritten to 05:00pm or 17:00 so that the content can be saved.

WordPress Environment

WordPress 5.2.2 with "Twenty Seventeen" theme and PODS Version 2.7.14

``` WordPress Version: 5.2.2

PHP Version: 7.1.30

MySQL Version: 5.5.41

Server Software: Apache/2.4

Your User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

Session Save Path: /nhldata/953/145953/tmp/phpsession

Session Save Path Exists: Yes

Session Save Path Writeable: Yes

Session Max Lifetime: 1440

Opcode Cache:

Apc: No
Memcached: No
OPcache: No
Redis: No
Object Cache:

APC: No
APCu: No
Memcache: No
Memcached: No
Redis: No
WPDB Prefix: wp_

WP Multisite Mode: No

WP Memory Limit: 40M

Current Memory Usage: 30,396M

Current Memory Usage (real): 2,000M

Pods Network-Wide Activated: No

Pods Install Location: /nhldata04/953/145953/data/web/bernaustaging/htdocs/wp-content/plugins/pods/

Pods Tableless Mode Activated: No

Pods Light Mode Activated: No

Currently Active Theme: Twenty Seventeen

Currently Active Plugins:

Pods - Custom Content Types and Fields: 2.7.14

</details>

## Pods Package Export (helpful!)

{"meta":{"version":"2.7.14","build":1566314273},"pods":{"26":{"id":26,"name":"agenda","label":"Agenda-Einträge","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":{"agenda-titlepicture":{"id":28,"name":"agenda-titlepicture","label":"Titelbild","description":"Ein Bild als Aushänger für die Veranstaltung","help":"","class":"","type":"file","weight":0,"pick_object":"custom-simple","pick_val":"","sister_id":"","required":"1","file_format_type":"single","file_uploader":"attachment","file_attachment_tab":"upload","file_edit_title":"1","file_show_edit_link":"0","file_linked":"0","file_limit":"0","file_restrict_filesize":"10MB","file_type":"images","file_field_template":"rows","file_add_button":"Add File","file_modal_title":"Attach a file","file_modal_add_button":"Add File","file_wp_gallery_output":"0","file_wp_gallery_link":"post","file_wp_gallery_columns":"1","file_wp_gallery_random_sort":"0","file_wp_gallery_size":"thumbnail","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","file_allowed_extensions":""},"agenda-datetime":{"id":29,"name":"agenda-datetime","label":"Datum / Zeit","description":"Datum und Zeit der Veranstaltung","help":"","class":"","type":"datetime","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"1","datetime_type":"format","datetime_format":"mdy","datetime_time_type":"12","datetime_time_format":"h_mma","datetime_time_format_24":"hh_mm","datetime_allow_empty":"1","datetime_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","datetime_repeatable":"0","datetime_format_custom":"","datetime_format_custom_js":"","datetime_time_format_custom":"","datetime_time_format_custom_js":""},"agenda-location":{"id":32,"name":"agenda-location","label":"Ort","description":"Veranstaltungsort","help":"","class":"","type":"text","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"1","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""}},"show_in_menu":"1","label_singular":"Agenda-Eintrag","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"agenda","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"1","pfat_run_outside_loop":"0","pfat_append_single":"replace","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"0","read_all":"0","write_all":"0","pfat_single":"Agenda Template","enable_i18n":{"de_DE":"1"}}},"templates":{"Agenda Template":{"id":39,"name":"Agenda Template","code":"<div class="agenda-full">\r\n\t<h1 class="entry-title">{@post_title}</h1>\r\n\t{@agenda-titlepicture._img.large}\r\n\t

{@agenda-datetime} - {@agenda-location}</p>\r\n\t

{@post_content}</p>\r\n</div>","type":"template","slug":"agenda-template","options":{"_edit_last":"1","_edit_lock":"1566312016:1","admin_only":"","restrict_capability":"","capability_allowed":"","pod_reference":"a:1:{s:3:"pod";s:6:"agenda";}"}}}}


## Workaround or Alternate Solution Until Bug is Addressed
Manually change the text in the field from e.g. "08/14/2019 02:00nachm." to either "08/14/2019 14:00" or "08/14/2019 02:00pm" before saving the content.

## Related Issues and/or PRs
Don't know any.
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label Type: Bug to this issue, with a confidence of 0.83. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@JoryHogeveen
Copy link
Member

JoryHogeveen commented Aug 21, 2019

Checked and validated.
The jQuery Timepicker translates AM/PM names depending on locale. PHP does not and also doesn't seem to recognize these translations (date_i18n from WP doesn't either).

I'm thinking about different options/todo:

  • File a bug report at WP about this so date_i18n. Though it seems to me that this is more a PHP related issue.
  • We could add our own translation matrix based on the jQuery Timepicker data.
    • Translate upon saving (24h format, always!)
    • Translate upon display (maybe make it an option?)

OR: Try to disable AM/PM translation from jQuery Timepicker.. (PR #5445 does this).

@sc0ttkclark Any ideas?

@JoryHogeveen
Copy link
Member

#5445 has become obsolete since #5451.
The latter is a way more solid solution for this issue.

@Kontsept If you can, please test PR #5451 and let us know if this fixes your issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment