function gdpr_consent_agreement_form in General Data Protection Regulation 7
Form for managing a consent agreement entity.
1 string reference to 'gdpr_consent_agreement_form'
- gdpr_consent_menu in modules/
gdpr_consent/ gdpr_consent.module - Implements hook_menu().
File
- modules/
gdpr_consent/ includes/ gdpr_consent.admin.inc, line 11 - Admin pages file for the GDPR Consent module.
Code
function gdpr_consent_agreement_form($form, &$form_state, GdprConsentAgreement $entity = NULL) {
$form['title'] = array(
'#title' => t('Title'),
'#type' => 'textfield',
'#default_value' => isset($entity->title) ? $entity->title : '',
'#description' => t('Agreement Title'),
'#required' => TRUE,
'#weight' => -50,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => isset($entity->name) ? $entity->name : '',
'#disabled' => $entity
->hasStatus(ENTITY_IN_CODE),
'#machine_name' => array(
'exists' => 'gdpr_consent_agreement_load_multiple_by_name',
'source' => array(
'title',
),
),
'#description' => t('A unique machine-readable name for this agreement. It must only contain lowercase letters, numbers, and underscores.'),
'#weight' => -50,
);
$form['agreement_type'] = array(
'#title' => t('Agreement Type'),
'#type' => 'select',
'#options' => array(
GDPR_CONSENT_TYPE_IMPLICIT => t('Implicit'),
GDPR_CONSENT_TYPE_EXPLICIT => t('Explicit'),
),
'#default_value' => isset($entity->agreement_type) ? $entity->agreement_type : '',
'#description' => t('Whether consent is implicit or explicit. Set to "Explicit" if the user needs to explicitly agree, otherwise "Implicit'),
);
$form['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => isset($entity->description) ? $entity->description : '',
'#description' => t('Text displayed to the user on the form'),
);
$form['long_description'] = array(
'#title' => t('Long Description'),
'#type' => 'textarea',
'#default_value' => isset($entity->long_description) ? $entity->long_description : '',
'#description' => t('Text shown when the user clicks for more details'),
);
$form['notes'] = array(
'#title' => t('Notes'),
'#type' => 'textarea',
'#default_value' => isset($entity->notes) ? $entity->notes : '',
'#description' => t('This should contain the rationale behind the agreement.'),
);
$form['revision'] = array(
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => 1,
);
$form['log'] = array(
'#type' => 'textarea',
'#title' => t('Revision log message'),
'#rows' => 4,
'#default_value' => !empty($entity->log) ? $entity->log : '',
'#description' => t('Briefly describe the changes you have made.'),
);
field_attach_form('gdpr_consent_agreement', $entity, $form, $form_state);
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => isset($entity->id) ? t('Update consent agreement') : t('Save consent agreement'),
),
);
return $form;
}