I am not familiar with the date API, as I have just started using it.
I wanted to use the API to help me create a form and save the date into the DB.
There was no documentation for that, so I added the section about forms with the php code in the handbook:
http://drupal.org/node/92187
This is what I have been able to figure out so far.
1) can you check there is no mistake
2) can you complete what is missing (i.e. that which I haven't figured out yet).
3) after that, the same documentation should be committed in date.inc with the rest of the documentation (or else remove the documentation from there, and provide a link to the handbook page).
Comments
Comment #1
beginner CreditAttribution: beginner commentedQuestions:
which function is handling the form_validate hook?
How do we get the value to insert into the DB from $form_values?
Comment #2
KarenS CreditAttribution: KarenS commentedThe API is changing in the HEAD version (which will become the 5.2 version). I've finally switched the way this works so it uses hook_elements() and has its own #process and #validate functions. Once it is all working well, I'll need to come back and get it all documented.
The new version is not ready for use. When it gets more reliable, I'll create a 5.2 branch where it can be tested.
Comment #3
beginner CreditAttribution: beginner commentedI am about to try to upgrade one module to D6. I hope it won't be too difficult without any documentation.
Comment #4
KarenS CreditAttribution: KarenS commentedThere is lots of internal documention in the functions.
The file date_api.module is basically a big collection of date utility functions. You can scan through the file and it should be pretty obvious what they are and what they do.
The date_api_xxx.inc files are files you can optionally include to do other things -- create cross-database date sql or work with ical. The date sql is implemented for views queries in date_api.views.inc, which should give you ideas on how to use it. The ical functions are implemented by the Calendar iCal module, which you can use as an example.
The basic date functions are the PHP 5.2 date functions -- date_create(), date_timezone_set(), date_format(), etc, all of which are documented on php.net.
The Date PHP4 module provides those 5.2 date functions for systems that don't have them (earlier than PHP 5.2).
The date_api_elements.inc creates date form elements - create a date selection form using type => '#date_select' and give it a few parameters (all documented in that file).
The Date Popup module will create a popup widget if you create a form and give it type=>'#date_popup' and a few other parameters documented in that file.
Someone needs to develop some good documentation, so maybe you can start some as you go?
Comment #5
KarenS CreditAttribution: KarenS commentedOh yes, and the Date Repeat module has an API for creating and parsing iCal RRULEs. You can use it to add a form element that allows users to select repeat rules (a form with type => '#date_repeat') and the repeat_calc function will parse an iCal RRULE and return an array of the dates that fit that rule.
Comment #6
beginner CreditAttribution: beginner commentedThanks for the information. I managed to understand almost all of what you say :) which was enough and helpful for what I had to do.
Notice that I already documented one year ago what I had managed to figure out then.
http://drupal.org/node/92187/revisions
I have just added an updated section for D6, on how to add a date field using the API.
Comment #7
beginner CreditAttribution: beginner commentedOk, I've managed to upgrade my module. The new API is easier to use (because more consistent with the Drupal FAPI). Thanks a lot.
I have documented what I've learned about your API.
You may want to ask others you are helping to document futher / better the parts that I have not used.
Comment #8
KarenS CreditAttribution: KarenS commentedSorry I overlooked your original effort and I appreciate what you've done.
Yes, I was trying to make things as consistent as possible with the way FAPI usually works. I'll leave this active and try to get back to it to build on what you started and make sure it's easy to find.
Thanks!
Comment #9
KarenS CreditAttribution: KarenS commentedI split the API documentation between the way it works in 5.1 and the way it works in 5.2 and 6.2 and moved the latter to a new page at http://drupal.org/node/287128. Since the documentation itself separates the different versions, we should have separate API pages for each.
Thanks again for getting this started :)
Comment #10
KarenS CreditAttribution: KarenS commentedI'm going to mark this fixed because it is at least started. Things like this are never 'done', and I'm trying to clean up the issue queue.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.