Issue #2193237 by czigor, amateescu, barraponto, revagomes, rodrigo panchiniak fernandes: Warning because of empty value at array_flip().

8.0.x
Alex Pott 2014-03-29 17:59:43 +01:00
parent b8c062c0ea
commit a6658cdd82
2 changed files with 20 additions and 3 deletions

View File

@ -71,8 +71,10 @@ class TaxonomyAutocompleteWidget extends WidgetBase {
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) {
$tags = array();
foreach ($items as $item) {
$tags[] = isset($item->entity) ? $item->entity : entity_load('taxonomy_term', $item->target_id);
if (!$items->isEmpty()) {
foreach ($items as $item) {
$tags[] = isset($item->entity) ? $item->entity : entity_load('taxonomy_term', $item->target_id);
}
}
$element += array(
'#type' => 'textfield',

View File

@ -17,7 +17,7 @@ class TermFieldTest extends TaxonomyTestBase {
*
* @var array
*/
public static $modules = array('entity_test');
public static $modules = array('entity_test', 'field_ui');
protected $instance;
protected $vocabulary;
@ -37,6 +37,7 @@ class TermFieldTest extends TaxonomyTestBase {
'view test entity',
'administer entity_test content',
'administer taxonomy',
'administer entity_test fields',
));
$this->drupalLogin($web_user);
$this->vocabulary = $this->createVocabulary();
@ -128,6 +129,20 @@ class TermFieldTest extends TaxonomyTestBase {
$this->assertNoFieldByName($this->field_name, '', 'Widget is not displayed.');
}
/**
* No php error message on the field setting page for autocomplete widget.
*/
function testTaxonomyTermFieldInstanceSettingsAutocompleteWidget() {
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->field_name, array(
'type' => 'taxonomy_autocomplete',
'weight' => 1,
))
->save();
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $this->field_name);
$this->assertNoErrorsLogged();
}
/**
* Tests that vocabulary machine name changes are mirrored in field definitions.
*/