You are here

public function LearningPathManagerController::getItemForm in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Controller/LearningPathManagerController.php \Drupal\opigno_learning_path\Controller\LearningPathManagerController::getItemForm()

Method called when the LP manager needs a create or edit form.

1 string reference to 'LearningPathManagerController::getItemForm'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathManagerController.php, line 63

Class

LearningPathManagerController
Controller for all the actions of the Learning Path manager app.

Namespace

Drupal\opigno_learning_path\Controller

Code

public function getItemForm(Group $group, $type = NULL, $item = 0) {

  // Get the good form from the corresponding content type.
  $content_type = $this->content_types_manager
    ->createInstance($type);
  $form = $content_type
    ->getFormObject($item);

  // Adds some information
  // used in the method opigno_learning_path_form_alter().
  $form_build = \Drupal::formBuilder()
    ->getForm($form, [
    'learning_path_info' => [
      'learning_path_id' => $group
        ->id(),
      'lp_content_type' => $type,
    ],
  ]);

  // Returns the form.
  return $form_build;
}