// Error if there are no entities available for a required field.
$form_state->setError($element,t('There are no entities matching "%value".',$params));
$form_state->setError($element,t('There are no @entity_type_plural matching "%value".',$params));
}
}
elseif(count($entities)>5){
$params['@id']=key($entities);
// Error if there are more than 5 matching entities.
$form_state->setError($element,t('Many entities are called %value. Specify the one you want by appending the id in parentheses, like "@value (@id)".',$params));
$form_state->setError($element,t('Many @entity_type_plural are called %value. Specify the one you want by appending the id in parentheses, like "@value (@id)".',$params));
}
elseif(count($entities)>1){
// More helpful error if there are only a few matching entities.
@@ -342,7 +343,7 @@ protected static function matchEntityByTitle(SelectionInterface $handler, $input
$multiples[]=$name.' ('.$id.')';
}
$params['@id']=$id;
$form_state->setError($element,t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".',['%multiple'=>strip_tags(implode('", "',$multiples))]+$params));
$form_state->setError($element,t('Multiple @entity_type_plural match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".',['%multiple'=>strip_tags(implode('", "',$multiples))]+$params));
@@ -279,7 +279,7 @@ public function testInvalidEntityAutocompleteElement() {
]);
$form_builder->submitForm($this,$form_state);
$this->assertCount(1,$form_state->getErrors());
$this->assertEqual($form_state->getErrors()['single'],t('There are no entities matching "%value".',['%value'=>'single - non-existent label']));
$this->assertEqual($form_state->getErrors()['single'],t('There are no test entity entities matching "%value".',['%value'=>'single - non-existent label']));
// Test 'single' with an entity ID that doesn't exist.
$form_state=(newFormState())
@@ -302,7 +302,7 @@ public function testInvalidEntityAutocompleteElement() {
// The element without 'autocreate' support still has to emit a warning when
// the input doesn't end with an entity ID enclosed in parentheses.
$this->assertCount(1,$form_state->getErrors());
$this->assertEqual($form_state->getErrors()['single_no_validate'],t('There are no entities matching "%value".',['%value'=>'single - non-existent label']));
$this->assertEqual($form_state->getErrors()['single_no_validate'],t('There are no test entity entities matching "%value".',['%value'=>'single - non-existent label']));