Skip Navigation

[Résolu] Data entry in date fields without datepicker

This support ticket is created Il y a 8 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 réponses, has 2 voix.

Last updated by futurecomi Il y a 8 années et 4 mois.

Assisted by: Waqas.

Auteur
Publications
#317150

Instead of using the datepicker we would prefer to copy/paste dates into date fields. As far as we can see this field type does not allow this. Any suggestions?

(We still want it to be a date field to use validation and formatting options, so we don't want to convert date fields into text fields.)

#317209

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

You can use following JavaScript code in JS editor of your CRED form:

jQuery(document).ready(function($){
    $("input.hasDatepicker").datepicker('disable');
    $("input.hasDatepicker").removeAttr('disabled');
    $("input.hasDatepicker").removeAttr('readonly');
});

It should do the trick disabling the Date Picker and enabling field for input. However, you must input the dates as the format was used by the Date Picker, so these are saved correctly.

Please let me know if I can help you with anything related.

#318831

My question is not related to the datepicker in CRED forms but in standard backend forms which are provided by the Types plug-in.

However, you are mentioning the date format. If I am having a look at the raw data in the database, my dates look like "1349395200" or even "-62208000". What format is that? Where can I find documentation on this?

#318873

I am able to answer the second half of my question myself: These (positive or negative) integer values are in the Unix timestamp format. So obviously it would not help to remove the datepicker if the users had to enter dates in this format. But it would help a lot if they could enter dates like "27.03.2015" or "2015-03-27". Any ideas?

#319064

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

To apply this in the backend, you need to add this in a separate .js file and enqueue as an admin script. Please see https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts for more information.

Yes, Types saves date type data as unix timestamp, while it takes input as a human readable format (i.e. "27.03.2015" or "2015-03-27"). So it doesn't matter if you disable the date-picker, all you need to input the date in the text field, as you have after selecting from the date-picker. So when form is submitted, Types takes care of it.

Storing dates in unix timestamp format, makes it highly searchable. Specially, when you want to apply date operations (between, from - to, days diff and etc). This is a standard among database storages.

#319305

Thank you for your answer, this should solve our problem for the moment. However it would be nice if the next version of Types could offer a checkbox "Display date picker" when defining a date field.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.