Skip to content
Snippets Groups Projects
Verified Commit 0b49065c authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2825712 by Utkarsh_33, lauriii, bnjmnm, tstoeckler, idebr, BramDriesen,...

Issue #2825712 by Utkarsh_33, lauriii, bnjmnm, tstoeckler, idebr, BramDriesen, Lendude, srishtiiee: The allowed values storage setting of list fields should be required

(cherry picked from commit 18432dac)
parent 4873ef5c
No related branches found
No related tags found
Loading
......@@ -77,6 +77,7 @@ protected static function extractAllowedValues($string, $has_data) {
return array_combine($keys, $labels);
}
return $values;
}
/**
......
......@@ -98,6 +98,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
'#field_name' => $this->getFieldDefinition()->getName(),
'#entity_type' => $this->getEntity()->getEntityTypeId(),
'#allowed_values' => $allowed_values,
'#required' => TRUE,
];
$element['allowed_values']['#description'] = $this->allowedValuesDescription();
......
......@@ -384,4 +384,27 @@ public function testNodeDisplay() {
}
}
/**
* Confirms the allowed value list is a required field.
*/
public function testRequiredPropertyForAllowedValuesList() {
$field_types = [
'list_float',
'list_string',
'list_integer',
];
foreach ($field_types as $field_type) {
$this->fieldName = "field_options_$field_type";
$this->createOptionsField($field_type);
// Try to proceed without entering any value.
$this->drupalGet($this->adminPath);
$this->submitForm([], 'Save field settings');
// Confirmation message that this is a required field.
$this->assertSession()->pageTextContains('Allowed values list field is required.');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment