D6.9 prepopulate CCK + Date fields
MatthewVance - February 3, 2009 - 22:08
| Project: | Prepopulate |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Far as I can tell the issue is that the field I'm after is within an fieldset with NO NAME.
the field i'm after is: name="field_event_datetime[value][date]"
HTML below:
<fieldset>
<legend>Event Date and Time </legend>
<div class="container-inline-date date-clear-block"><div id="edit-field-event-datetime-value-wrapper" class="form-item">
<label for="edit-field-event-datetime-value">Event Date and Time From date: <span title="This field is required." class="form-required">*</span></label>
<div id="edit-field-event-datetime-value-datepicker-popup-0-wrapper" class="form-item">
<input type="text" class="form-text" value="Feb 3 2009" size="20" id="edit-field-event-datetime-value-datepicker-popup-0" name="field_event_datetime[value][date]" maxlength="30"/>
<div class="description"> Format: Feb 3 2009</div>
</div><
<div id="edit-field-event-datetime-value-timeEntry-popup-1-wrapper" class="form-item">
<input type="text" class="form-text" value="04:45PM" size="10" id="edit-field-event-datetime-value-timeEntry-popup-1" name="field_event_datetime[value][time]" maxlength="10"/>
<div class="description">Format: 04:45PM</div>
</div>
</div>
</div><div class="container-inline-date date-clear-block"><div id="edit-field-event-datetime-value2-wrapper" class="form-item">
<label for="edit-field-event-datetime-value2">Event Date and Time To date: </label>
<div id="edit-field-event-datetime-value2-datepicker-popup-0-wrapper" class="form-item">
<input type="text" class="form-text" value="Feb 3 2009" size="20" id="edit-field-event-datetime-value2-datepicker-popup-0" name="field_event_datetime[value2][date]" maxlength="30"/>
<div class="description"> Format: Feb 3 2009</div>
</div>
<div id="edit-field-event-datetime-value2-timeEntry-popup-1-wrapper" class="form-item">
<input type="text" class="form-text" value="04:45PM" size="10" id="edit-field-event-datetime-value2-timeEntry-popup-1" name="field_event_datetime[value2][time]" maxlength="10"/>
<div class="description">Format: 04:45PM</div>
</div>
#1
OK Just a quick update, I have solved this issue on my own.
At least with the date-time field, I hacked the .module to dump the form variables just to see what was going on.
What I FOUND was the date "value" was in a different format than what was showing up in the form.
ie: in the form it showed "Feb 4 2009" but in the raw variable it showed as "2009-02-04".
After changing the format I was populating the field with, this module worked perfectly with this CCK field within a fieldset.
SO, you MIGHT have to do a bit of digging about the underlying format of your variable data before you can populate some CCK fields.
At least until the developers figure out a way to check for this type of stuff, or I do.
LOVE the module guys, keep up the great work!
#2
Date fields work so long as you pass the date to them in the right native format for the type of date you are using. Ignore the way the date looks in the form, it's the way the date is stored in the database that you need:
1) Date field: YYYY-MM-DDTHH:MM:SS
2) Datetime field: YYYY-MM-DD HH:MM:SS
3) Datestamp field: 1234567899
#3
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
Upon further reflection, you did sort of say how you did it here. Sort of.
#6
In case this can save anybody else some time, I was having trouble prepopulating this: field_bed_occupied_datestamp[0][value][date].
The full input element I'm trying to prepopulate with a datestamp looks like this:
<input type="text" maxlength="30" name="field_bed_occupied_datestamp[0][value][date]" id="edit-field-bed-occupied-datestamp-0-value-datepicker-popup-0" size="20" value="" class="form-text" /><div class="description"> Format: 10/30/2009</div>
Here's the trick:
1. As mentioned above, you need to use the format that your database is using (which you select when you create the CCK field, in my case datestamp, which is a UNIX timestamp)
2. You have to drop [date] from the name. I don't know why it works like this. But it works.
Example:
mydomain.com/node/add/some-node-type?edit[field_bed_occupied_datestamp][0][value]=1254628800
prepopulates the date field with: 10/30/09.
#7
Date and Datetime work fine. But Datestamp is misbehaving. After spending all morning with this, here's what I know...
These work:
?edit[field_bed_occupied_date][0][value]=2009-07-23T00:00:00
?edit[field_bed_occupied_datetime][0][value]=2009-07-23 00:00:00
Both of these prepopulate my date field with 7/23/09.
This doesn't:
?edit[field_bed_occupied_datestamp][0][value]=1248321600
I know I just posted a few hours ago saying datestamp works fine. Here's what I missed: The query above will populate the date field with something. But the thing getting prepopulated is wrong. It seems to be the date from the formatting help text below the input box. No mater what datestamp I put as a parameter, the field is getting prepopulated with 10/30/09.