You are here

function notifications_subscription_form_field in Notifications 6.2

Same name and namespace in other branches
  1. 6 notifications.module \notifications_subscription_form_field()
  2. 6.3 notifications.module \notifications_subscription_form_field()

Display a form field for a notifications_field

1 call to notifications_subscription_form_field()
notifications_add_subscription_form in ./notifications.pages.inc
Form for creating new subscriptions

File

./notifications.module, line 1732
Notifications module

Code

function notifications_subscription_form_field($type, $value = NULL, $subtype = NULL) {
  $info = notifications_subscription_fields($type);
  if (!empty($info['options callback'])) {
    $element['#type'] = 'select';
    if (!empty($info['options callback args'])) {
      $element['#options'] = call_user_func($info['options callback'], $subtype, $info['options callback args']);
    }
    else {
      $element['#options'] = call_user_func($info['options callback'], $subtype);
    }
  }
  elseif (!empty($info['autocomplete path'])) {
    $element['#type'] = 'textfield';
    $element['#autocomplete_path'] = $info['autocomplete path'];
    if ($value) {
      if (!empty($info['autocomplete callback'])) {
        if (!empty($info['autocomplete callback args'])) {
          $value = call_user_func($info['autocomplete callback'], $value, $subtype, $info['autocomplete callback args']);
        }
        else {
          $value = call_user_func($info['autocomplete callback'], $value, $subtype);
        }
      }
      elseif (!empty($info['format callback'])) {
        if (!empty($info['format callback args'])) {
          $value = call_user_func($info['format callback'], $value, FALSE, $subtype, $info['format callback args']);
        }
        else {
          $value = call_user_func($info['format callback'], $value, FALSE, $subtype);
        }
      }
    }
  }
  else {
    $element['#type'] = 'textfield';
    if ($value) {
      $value = check_plain($value);
    }
  }
  if ($value) {
    $element['#default_value'] = $value;
  }
  return $element;
}