Fix TypeError: Argument 1 passed to Drupal\Core\Entity\EntityStorageBase::loadMultiple() must be of the type array or null, string given.
This error occurs if ?asset=X is used instead of ?asset[]=X. We can take a more defensive approach by automatically wrapping the input in an array if it isn't already one.
This commit is contained in:
parent
345464c6ad
commit
08c50d7fde
|
@ -61,6 +61,11 @@ function farm_log_entity_prepare_form(EntityInterface $entity, $operation, FormS
|
|||
/** @var \Drupal\Core\Field\EntityReferenceFieldItemList $asset_field */
|
||||
$asset_field = $entity->get('asset');
|
||||
|
||||
// Wrap in an array, if necessary.
|
||||
if (!is_array($asset_ids)) {
|
||||
$asset_ids = [$asset_ids];
|
||||
}
|
||||
|
||||
// Add each asset the user has view access to.
|
||||
$assets = \Drupal::entityTypeManager()->getStorage('asset')->loadMultiple($asset_ids);
|
||||
foreach ($assets as $asset) {
|
||||
|
|
Loading…
Reference in New Issue