Commit 00b6a1fe authored by alexpott's avatar alexpott

Revert "Issue #2762953 by cilefen, gisle, drumm: Select elements should use strict comparison"

This reverts commit 2893aec5.
parent 3f1ad36a
......@@ -113,7 +113,7 @@ function form_select_options($element, $choices = NULL) {
$option = [];
$key = (string) $key;
$empty_choice = $empty_value && $key == '_none';
if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'], TRUE))) || $empty_choice)) {
if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value']))) || $empty_choice)) {
$option['selected'] = TRUE;
}
else {
......
......@@ -325,49 +325,6 @@ function testSelectListSingle() {
$edit = array('card_1' => '_none');
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$this->assertFieldValues($entity_init, 'card_1', array());
// Create field storage with string keys.
$field_storage = FieldStorageConfig::create([
'field_name' => 'select_a',
'entity_type' => 'entity_test',
'type' => 'list_string',
'cardinality' => 1,
'settings' => [
'allowed_values' => [
'7.50' => '7.50',
'7.5' => '7.5',
],
],
]);
$field_storage->save();
// Create a list_string field instance.
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'required' => TRUE,
]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_storage->getName(), array(
'type' => 'options_select',
))
->save();
// Create and save an entity.
$entity = EntityTest::create(array(
'user_id' => 1,
'name' => $this->randomMachineName(),
));
$entity->save();
// Ensure string keys are properly marked selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
$edit = array('select_a' => '7.50');
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$this->assertFieldValues($entity, 'select_a', array('7.50'));
$this->assertOptionSelected('edit-select-a', '7.50');
$this->assertNoOptionSelected('edit-select-a', '7.5');
}
/**
......
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