You are here

function commerce_discount_date_popup_process_alter in Commerce Discount 7

Implements hook_date_popup_process_alter().

File

includes/commerce_discount.admin.inc, line 478
Commerce discount editing UI.

Code

function commerce_discount_date_popup_process_alter(&$element, &$form_state, $context) {
  if (isset($element['#field']) && $element['#field']['field_name'] == 'commerce_discount_date') {

    // Date-clear.
    unset($element['#attributes']['class']);
    array_shift($element['#wrapper_attributes']['class']);

    // Reset the titles and descriptions of the start and end date fields.
    $field_name = end($element['#parents']);
    if ($field_name == 'value') {
      $element['date']['#title'] = t('Start date');
      $element['date']['#description'] = t('Starts at 12:00:00 AM');
    }
    else {
      $element['date']['#title'] = t('End date');
      $element['date']['#description'] = t('Ends after 11:59:59 PM');
    }
    $element['#title'] = '';
  }
}