You are here

function invite_type_form in Invite 7.4

Generates the invite type editing form.

_state

Parameters

$form:

InviteType $invite_type:

string $op:

Return value

array

File

includes/invite.admin.inc, line 17

Code

function invite_type_form($form, &$form_state, $invite_type, $op = 'edit') {
  if ($op == 'clone') {
    $invite_type->label .= ' (cloned)';
    $invite_type->type = '';
  }
  $form['#invite_type'] = $invite_type;
  $invite_sending_controllers = array();
  foreach (module_implements('invite_sending_controller') as $module) {
    $sending_controller = module_invoke($module, 'invite_sending_controller');
    $invite_sending_controllers[$module] = $sending_controller['label'];
  }
  if (empty($invite_sending_controllers)) {
    $form['message'] = array(
      '#markup' => t('Sorry no Invitation Type modules available in the system.'),
    );
    return $form;
  }
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => $invite_type->label,
    '#description' => t('The human-readable name of this invite type.'),
    '#required' => TRUE,
    '#size' => 30,
  );

  // Machine-readable type name.
  $form['type'] = array(
    '#type' => 'machine_name',
    '#default_value' => isset($invite_type->type) ? $invite_type->type : '',
    '#maxlength' => 32,
    '#disabled' => $invite_type
      ->isLocked() && $op != 'clone',
    '#machine_name' => array(
      'exists' => 'invite_get_types',
      'source' => array(
        'label',
      ),
    ),
    '#description' => t('A unique machine-readable name for this invite type. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#default_value' => isset($invite_type->description) ? $invite_type->description : '',
    '#description' => t('Description about the invite type.'),
  );
  $form['invite_sending_controller'] = array(
    '#title' => t('Sending method'),
    '#type' => 'checkboxes',
    '#default_value' => $invite_type->invite_sending_controller,
    '#description' => t('Invitation processing plugin.'),
    '#options' => $invite_sending_controllers,
    '#required' => TRUE,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save invite type'),
    '#weight' => 40,
  );
  if (!$invite_type
    ->isLocked() && $op != 'add' && $op != 'clone') {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete invite type'),
      '#weight' => 45,
      '#limit_validation_errors' => array(),
      '#submit' => array(
        'invite_type_form_submit_delete',
      ),
    );
  }
  return $form;
}