Tell us what you are trying to do?
My client is asking me to change two custom fields type. Currently they are Field Type of Date. Now they want to make it a so that they can type in the date instead of Selecting it using DatePicker. I'm thinking that converting the Custom Fields to Type of Single Text will allow them to enter date manually. What advice or suggestion do you have and are their any drawbacks with converting Date to Single Field that I should consider and keep in mind? Are their any other options to leave the fields as Date Field Type but also allow user to manually enter the date?
Hello,
The custom date field created by Types will stores value in Timestamp format, I don't think it is good idea: change it to single line field, ordinary user won't be able to input the correct timestamp value.
For the question:
Are their any other options to leave the fields as Date Field Type but also allow user to manually enter the date?
There isn't such a built-in feature within Toolset Types plugin, you might consider custom codes, for example:
1) Create another custom single line field "my-date-2"
2) After user input the date value into above single line field, and save the post, use action hook save_post to trigger a PHP function,
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Get the value of single line field "my-date-2", turn it into timestamp format, and save it into your custom date field.
For your reference.
Thanks Luo.
So what if we do this...
1) Convert the Date field to Single Line (not create a new one).
2) Hook into the cred_submit_complete Action and convert the inputed date to timestamp and store it?
This would do similar to your suggestion but avoid creating a new field. When I display the date I will convert back to proper formatted date.
Thanks,
Mukesh
Hi Luo, after thinking through the solutions I think the option you provide or creating a second field and then behind the scenes updating the existing Date field is probably the best option. If I had converted the existing Date field to Single Line, then I would have had to update every View and Form to format the display and that would be a lot of time. With your option I just need to update the Forms where I ask for Date of Birth and create the Hook function to update the Date field then all the views and forms stay in tact.
Thanks for the solution.
My issue is resolved now. Thank you!