public function ContentTypeCourse::getFormObject in Opigno course 3.x
Same name and namespace in other branches
- 8 src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php \Drupal\opigno_course\Plugin\OpignoGroupManagerContentType\ContentTypeCourse::getFormObject()
Get the form object based on the entity ID.
If no entity given in parameter, return the entity creation form object.
Parameters
int $entity_id: The entity ID.
Return value
\Drupal\Core\Entity\EntityFormInterface Form.
Overrides ContentTypeInterface::getFormObject
File
- src/
Plugin/ OpignoGroupManagerContentType/ ContentTypeCourse.php, line 294
Class
- ContentTypeCourse
- Class ContentTypeCourse.
Namespace
Drupal\opigno_course\Plugin\OpignoGroupManagerContentTypeCode
public function getFormObject($entity_id = NULL) {
if (empty($entity_id)) {
$form = \Drupal::entityTypeManager()
->getFormObject($this
->getEntityType(), 'add');
$entity = Group::create([
'type' => 'opigno_course',
]);
}
else {
$form = \Drupal::entityTypeManager()
->getFormObject($this
->getEntityType(), 'edit');
$entity = Group::load($entity_id);
}
$form
->setEntity($entity);
return $form;
}