By lebachai on
I have installed the latest versions of JSCalendar, CCK and the date modules, and no matter what I do, whenever a date CCK field is submitted using dates chosen from JSCalendar, it comes up with this error:
(name of field) must be entered in ISO 8601 format (YYYY-MM-DDThh:mm:ss).
I get this error for each date field using JSCalendar. Here's the code I'm using to attach JSCalendar to the date fields:
<?php
function date_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
//set this to the type of content you want to publish on
if ($form['type']['#value'] == 'content-employment_opportunity') {
$form['field_expiration_date'][0]['value']['#attributes'] = array('class' => 'jscalendar');
$form['field_deadline_for_application'][0]['value']['#attributes'] = array('class' => 'jscalendar');
$form['field_publish_date'][0]['value']['#attributes'] = array('class' => 'jscalendar');
// Use only year, month, and day in textfield.
$form['#jscalendar_ifFormat'] = '%Y-%m-%d';
// Don't show time.
$form['#jscalendar_showsTime'] = 'false';
}
}
}
?>
I figure that I am doing something wrong, but I cannot figure out what. Any help would be very appreciated.
Comments
Why are you doing it with
Why are you doing it with form_alter? If you select the jscalendar widget in your date field it will supply the right code to make it work.
Text field is only widget available
I used this code because there was no option to select anything but a text field. I could not find any other way to configure the system to use JSCalendar.
If you have js calendar
If you have js calendar enabled, you should see a widget called 'Text Field with javascript pop-up calendar', which is what you would select. This should work fine in 4.7. I don't know if jscalendar is ported to 5.x yet, so I don't know if it is working in 5.x.
No such widget...
I have tried re-installing and re-enabling both the date and the jstools/jscalendar modules and re-creating my CCK fields, to no avail. The only widget I am ever offered with date fields is a text field (plain, no JSCalendar option). Any idea what I'm missing?
What Drupal version are you
What Drupal version are you using (4.7 or 5.x)? If it's 5.x, I need to see if there have been changes in the way jscalendar works that is affecting this. If it's 4.7, it *should* be working, so we need to dig into it more.
Try uninstalling all contrib modules except cck, date, and jscalendar, then see if anything behaves differently (just in case the problem is actually coming from some other module).
Followed your instructions...
Unfortunately, with no positive results. Perhaps you could provide some step-by-step instructions for getting this working and I could start over? This is getting very frustrating and I feel like I am missing something obvious. Nothing else with Drupal has stalled my progress like this particular issue. Any help would be greatly appreciated!
What version are you using,
What version are you using, 4.7 or 5.x? You still have not answered that question and I can't help you without knowing that.
If you're using 5.x, there was a problem with JSCalendar that was just fixed (http://drupal.org/node/81691). And, obviously, you need the 5.x version of JSCalendar.
Sorry, it's 4.7x
Thanks for your help!
Finally fixed it
I don't know what happened, but I disabled, uninstalled, reinstalled and ran update.php (again) and now I have the widget option. Go figure. Obviously I screwed up something the first few times around, but I guess I'll never know what it was. Thanks for your help though!