public function HeartbeatTypeForm::getBundlesForEntity in Heartbeat 8
Custom form validation to rebuild Form field for mapping Message Arguments
File
- src/
Form/ HeartbeatTypeForm.php, line 403
Class
- HeartbeatTypeForm
- Class HeartbeatTypeForm.
Namespace
Drupal\heartbeat\FormCode
public function getBundlesForEntity(array &$form, FormStateInterface $form_state) {
$entityType = $this->entityTypes[$form_state
->getValue('entity_type')];
$entity = $this->entityTypeManager
->getStorage($entityType);
$bundleTypeName = $entity
->getEntityType()
->getBundleEntityType();
$bundles = $this->entityTypeManager
->getStorage($bundleTypeName)
->loadMultiple();
$bundleNames = array();
foreach ($bundles as $bundle) {
$bundleNames[] = $bundle
->id();
}
$form_state
->set('entity_bundles', $bundleNames);
// $form['entity_bundles']['#options'] = array($bundleNames);
$form_state
->setRebuild();
return $form['entity_bundles'];
}