function CourseOutlineForm::ajaxCallback in Course 8.2
Same name and namespace in other branches
- 8.3 src/Form/CourseOutlineForm.php \Drupal\course\Form\CourseOutlineForm::ajaxCallback()
- 3.x src/Form/CourseOutlineForm.php \Drupal\course\Form\CourseOutlineForm::ajaxCallback()
Handle the "Add object" AJAX event.
File
- src/
Form/ CourseOutlineForm.php, line 259
Class
Namespace
Drupal\course\FormCode
function ajaxCallback($form, FormStateInterface $form_state) {
return $form['course_outline'];
// Maybe pop up a modal later.
/**
$course = $form_state->getBuildInfo()['args'][0];
$object_id = $form_state->getValue('last');
$object_form = \Drupal::formBuilder()->getForm('\Drupal\course\Form\CourseObjectForm', $course, $object_id);
$object_form['#action'] = \Drupal::url('course.object.options', ['course' => $course->id(), 'course_object' => $object_id], ['query' => ['destination' => \Drupal::destination()]]);
$command = new \Drupal\Core\Ajax\OpenModalDialogCommand('New object', $object_form, ['width' => '75%']);
$response = new \Drupal\Core\Ajax\AjaxResponse();
$response->addCommand($command);
return $response;
*/
}