Skip to content

Instantly share code, notes, and snippets.

@jec006
Created July 30, 2012 18:52
Show Gist options
  • Save jec006/3209128 to your computer and use it in GitHub Desktop.
Save jec006/3209128 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements WidgetInterface::getPreviewForm().
*
* Return a form to collect the date information from the user.
*/
public function getPreviewForm($element, &$form_state) {
$element['#type'] = 'fieldset';
$element['#title'] = empty($this->settings['title']) ? t('Date/Time:') : $this->settings['title'];
$element['#description']= t('Preview nodes published on or after this date.');
$element['#attributes']['class'] = array('sps-date-widget');
$element['preview_date'] = array(
'#type' => 'date_popup',
'#title' => t('Date to Preview'),
'#default_value' => isset($form_state['values']['preview_date']) ? $form_state['values']['preview_date'] : NULL,
);
//have a fallback if they don't have date_popup installed.
if (!module_exists('date_popup')) {
$element['preview_data']['#type'] = 'date';
$element['preview_time'] = array(
'#type' => 'textfield',
'#title' => t('Time'),
'#size' => 9,
'#default_value' => isset($form_state['values']['preview_time']) ? $form_state['values']['preview_time'] : '00:00:00',
);
}
return $element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment