You are here

function crm_core_activity_type_form in CRM Core 7

Generates the profile type editing form.

File

modules/crm_core_activity/crm_core_activity.admin.inc, line 11
Provides basic activity management functionality in CRM Core.

Code

function crm_core_activity_type_form($form, &$form_state, $crm_activity_type, $op = 'edit') {
  if ($op == 'clone') {
    $crm_activity_type->label .= ' (cloned)';
    $crm_activity_type->type = '';
  }
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => $crm_activity_type->label,
    '#description' => t('The human-readable name of this profile type.'),
    '#required' => TRUE,
    '#size' => 30,
  );

  // Machine-readable type name.
  $form['type'] = array(
    '#type' => 'machine_name',
    '#default_value' => isset($crm_activity_type->type) ? $crm_activity_type->type : '',
    '#maxlength' => 32,
    '#disabled' => $crm_activity_type
      ->isLocked() && $op != 'clone',
    '#machine_name' => array(
      'exists' => 'crm_core_activity_types',
      'source' => array(
        'label',
      ),
    ),
    '#description' => t('A unique machine-readable name for this profile type. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#default_value' => isset($crm_activity_type->description) ? $crm_activity_type->description : '',
    '#description' => t('Description about the activity type.'),
  );
  $form['activity_string_container'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
  );
  $form['activity_string_container']['activity_string'] = array(
    '#type' => 'textfield',
    '#title' => t('Activity string'),
    '#description' => t('Enter text describing the relationship between the contact and this activity. For example: Someone Somewhere registered for this activity.'),
    '#default_value' => empty($crm_activity_type->activity_string) ? '' : $crm_activity_type->activity_string,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save activity type'),
    '#weight' => 40,
  );
  if (!$crm_activity_type
    ->isLocked() && $op != 'add') {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete activity type'),
      '#weight' => 45,
      '#limit_validation_errors' => array(),
      '#submit' => array(
        'crm_core_activity_type_form_submit_delete',
      ),
    );
  }
  return $form;
}