You are here

function entity_legal_document_acceptance_form in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 entity_legal.module \entity_legal_document_acceptance_form()

Form callback for legal document acceptance form.

1 string reference to 'entity_legal_document_acceptance_form'
EntityLegalDocument::getAcceptanceForm in ./entity_legal.entity.inc
Get an acceptance form for this legal document.

File

./entity_legal.module, line 352
Entity Legal module.

Code

function entity_legal_document_acceptance_form($form, &$form_state, EntityLegalDocument $entity_legal_document) {
  $form_state[ENTITY_LEGAL_DOCUMENT_ENTITY_NAME] = $entity_legal_document;
  $has_agreed = $entity_legal_document
    ->userHasAgreed();
  $form['agree'] = array(
    '#title' => $entity_legal_document
      ->getAcceptanceLabel(),
    '#type' => 'checkbox',
    '#required' => TRUE,
    '#default_value' => $has_agreed,
    '#disabled' => $has_agreed,
  );
  if ($has_agreed) {
    global $user;
    $acceptances = $entity_legal_document
      ->getAcceptances($user);
    if (!empty($acceptances)) {
      $form['agree']['#description'] = render(entity_view(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME, $acceptances));
    }
  }
  $form['submit'] = array(
    '#value' => t('Submit'),
    '#type' => 'submit',
    '#access' => !$has_agreed,
  );
  return $form;
}