Skip to content
Snippets Groups Projects
Commit 1b252e29 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2167975 by amateescu, swentel: Entity_reference_create_instance does...

Issue #2167975 by amateescu, swentel: Entity_reference_create_instance does not support cardinality.
parent 2d5138fc
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -191,10 +191,12 @@ function entity_reference_query_entity_reference_alter(AlterableInterface $query
* @param array $selection_handler_settings
* An array of settings supported by the selection handler specified above.
* (e.g. 'target_bundles', 'sort', 'auto_create', etc).
* @param int $cardinality
* The cardinality of the field.
*
* @see \Drupal\entity_reference\Plugin\entity_reference\selection\SelectionBase::settingsForm()
*/
function entity_reference_create_instance($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array()) {
function entity_reference_create_instance($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array(), $cardinality = 1) {
// If a field type we know should exist isn't found, clear the field cache.
if (!\Drupal::service('plugin.manager.field.field_type')->getDefinition('entity_reference')) {
field_cache_clear();
......@@ -209,6 +211,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f
'name' => $field_name,
'type' => 'entity_reference',
'entity_type' => $entity_type,
'cardinality' => $cardinality,
'settings' => array(
'target_type' => $target_entity_type,
),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment