function opigno_certificate_form_alter in Opigno certificate 8
Same name and namespace in other branches
- 3.x opigno_certificate.module \opigno_certificate_form_alter()
Implements hook_form_alter().
File
- ./
opigno_certificate.module, line 253 - Contains opigno_certificate.module.
Code
function opigno_certificate_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, [
'opigno_certificate_wysiwyg_add_form',
'opigno_certificate_wysiwyg_edit_form',
])) {
$form['body']['widget'][0]['#format'] = 'opigno_certificate_wysiwyg';
$form['field-comments'] = [
'#type' => 'details',
'#title' => t('Body tokens'),
'#open' => TRUE,
];
$form['field-comments']['tokens'] = [
'#type' => 'item',
'#title' => t('Tokens'),
'#markup' => '<p>The following tokens are available, and make possible to have some information about user data, training\'s name, completion date automatically inserted into the certificate when it is issued.</p>
<ul>
<li>Training title - [opigno_certificate:referencing_entity]</li>
<li>Training completed on date - [opigno_certificate:created]</li>
<li>Training certificate expiration date - [group:expiration_date]</li>
<li>User who completed training - [current-user:display-name]</li>
<li>Certificate title - [opigno_certificate:label]</li>
<li>Certificate author - [opigno_certificate:uid:entity:display-name]</li>
</ul>',
];
}
// Make field uid required.
$array_form_ids = [
'opigno_certificate_template_add_form',
'opigno_certificate_template_edit_form',
'opigno_certificate_wysiwyg_edit_form',
'opigno_certificate_wysiwyg_add_form',
];
if (in_array($form_id, $array_form_ids)) {
$form['uid']['widget'][0]['target_id']['#required'] = TRUE;
}
unset($form["paper_orientation"]["widget"]["#options"]["_none"]);
$form["actions"]["#weight"] = 125;
}