function opigno_course_form_alter in Opigno course 3.x
Same name and namespace in other branches
- 8 opigno_course.module \opigno_course_form_alter()
Implements hook_form_alter().
File
- ./
opigno_course.module, line 31 - Contains opigno_course.module.
Code
function opigno_course_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, [
'group_opigno_course_edit_form',
'group_opigno_course_add_form',
])) {
unset($form['badge_criteria']['widget']['#options']['_none']);
if (\Drupal::moduleHandler()
->moduleExists('opigno_module')) {
$form['#attached']['library'][] = 'opigno_module/opigno_badges';
}
}
$destination = \Drupal::request()
->get('destination', FALSE);
if ($destination === FALSE || substr($destination, -14) != 'course-content') {
return;
}
$destination_parts = explode('/', $destination);
$destination_id = $destination_parts[3];
if (!is_numeric($destination_id)) {
return;
}
}