You are here

public function Notifications_Subscription::get_form in Notifications 7

Get form for this subscription

Return value

$form

File

./notifications.subscription.inc, line 442
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Common base for subscription type and subscription instance

Code

public function get_form($operation, $form, &$form_state) {
  $form['subscription'] = array(
    '#type' => 'value',
    '#value' => $this,
  );
  $form['operation'] = array(
    '#type' => 'value',
    '#value' => $operation,
  );
  switch ($operation) {
    case 'subscribe':

      // This case will be editable if not all fields are predefined
      $editable = count($this
        ->get_fields()) > count($this
        ->get_fields(TRUE));
      break;
    case 'edit':
      $editable = TRUE;
      break;
    case 'unsubscribe':
    case 'delete':
    default:
      $editable = FALSE;
      break;
  }
  if ($editable) {
    $form = $this
      ->form_edit($operation, $form, $form_state);
  }
  else {
    $form = $this
      ->form_view($operation, $form, $form_state);
  }
  $form['controls'] = $this
    ->element_operation($operation);
  return $form;
}