You are here

function entity_legal_document_version_form in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 entity_legal.admin.inc \entity_legal_document_version_form()

Generates the profile type editing form.

1 string reference to 'entity_legal_document_version_form'
EntityLegalDocumentVersionUIController::hook_forms in ./entity_legal.entity_admin.inc
Provides definitions for implementing hook_forms().

File

./entity_legal.admin.inc, line 273
Administration hooks and helpers for entity_legal module.

Code

function entity_legal_document_version_form($form, &$form_state, EntityLegalDocumentVersion $entity, $op = 'edit', $entity_type = NULL) {
  $form['label'] = array(
    '#title' => t('Title'),
    '#type' => 'textfield',
    '#default_value' => isset($entity->label) ? $entity->label : '',
    '#required' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#title' => t('Machine-readable name'),
    '#required' => TRUE,
    '#default_value' => isset($entity->name) ? $entity->name : $entity->document_name . '_' . time(),
    '#machine_name' => array(
      'exists' => 'entity_legal_document_version_name_exists',
    ),
    '#access' => $op == 'add' || $op == 'clone',
    '#maxlength' => 64,
  );
  field_attach_form(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME, $entity, $form, $form_state);
  $form['acceptance_label'] = array(
    '#title' => t('Acceptance label'),
    '#type' => 'textfield',
    '#description' => t('e.g. I agree to the terms and conditions'),
    '#default_value' => isset($entity->acceptance_label) ? $entity->acceptance_label : t('I agree'),
    '#weight' => 50,
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 51,
  );
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 1,
  );

  // Remove unnecessary Entity API validation and submit handlers.
  $form['#validate'] = array();
  $form['#submit'] = array(
    'entity_legal_document_version_form_submit',
  );
  return $form;
}