Commit 1b252e29 authored by alexpott's avatar alexpott

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
......@@ -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,
),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment