function publication_date_pubdate_validate in Publication Date 7
Same name and namespace in other branches
- 7.2 publication_date.module \publication_date_pubdate_validate()
Node edit form validation handler.
Validate the published date input.
1 string reference to 'publication_date_pubdate_validate'
- publication_date_form_node_form_alter in ./
publication_date.module - Implementation of hook_form_BASE_ID_alter().
File
- ./
publication_date.module, line 142 - Add a field to nodes containing the publication date.
Code
function publication_date_pubdate_validate($form, &$form_state) {
// Validate the "Published on" field. As of PHP 5.1.0, strtotime returns FALSE
// instead of -1 upon failure.
if (!empty($form_state['values']['pubdate'])) {
if (strtotime($form_state['values']['pubdate']) <= 0) {
form_set_error('pubdate', t('You have to specify a valid date for the published on field.'));
}
}
}