You are here

function commerce_node_checkout_expire_field_widget_form in Commerce Node Checkout 7

Implements hook_field_widget_form().

File

commerce_node_checkout_expire/commerce_node_checkout_expire.module, line 109
Provides core hooks and the like for the module.

Code

function commerce_node_checkout_expire_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $widget = $element;
  $widget['#delta'] = $delta;
  switch ($instance['widget']['type']) {
    case 'commerce_node_checkout_expire_notification':

      // Extract the enabled status
      $enabled = isset($items[$delta]['enabled']) ? $items[$delta]['enabled'] : 1;

      // Extract the sent status
      $sent = isset($items[$delta]['sent']) ? $items[$delta]['sent'] : 0;

      // Build the widget
      $widget += array(
        '#type' => 'radios',
        '#options' => array(
          1 => t('Enabled'),
          0 => t('Disabled'),
        ),
        '#default_value' => $enabled,
      );
      $element['enabled'] = $widget;

      // Store the value for sent
      $element['sent'] = array(
        '#type' => 'value',
        '#value' => $sent,
      );
      break;
  }
  return $element;
}