Hello!
I've written a little validation for an event-contenttype that displays an error, if the date is in the past. Here we go:
function _mymodule_event_node_form_validate($form, &$form_state) {
$creationTS = time();
$eventTS = $form_state['values']['field_event_datetime']['0']['value'] + $form_state['values']['field_event_datetime']['0']['offset'];
if(($eventTS - $creationTS) < 0) {
form_set_error('field_event_datetime', t('Don't use a date in the past.'));
}
}
So this works, but I am looking for a way to set the error not for the hole field_event_datetime form element, but for a part of it (just the date-field). Printing out $form shows this Array:
Array
(
[#id] => node-form
[nid] => Array
(
[#type] => value
[#value] =>
[#post] => Array
(
[title] => mein termin :D
[field_termin_datetime] => Array
(
[value] => Array
(
[date] => 02.03.2010
[time] => 20:00
)
So I thought I can use form_set_error('field_event_datetime[value][date]', t('Don't use a date in the past.')); or something similar - but had no luck. Can you tell me how to adress this date form element?! The HTML-Code of it is also with [] brackets: <input type="text" maxlength="30" name="field_termin_datetime[value][date]" id="edit-field-termin-datetime-value-datepicker-popup-0" size="20" value="02.03.2010" class="form-text" />
Thanks for any hint - regards, Freddy
Comments
Comment #1
freddyseubert commentedSorry, was wrong version.
Comment #2
kars-t commentedHi
I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.
Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.