Verified Commit 18432dac 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
parent 677faa7b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ protected static function extractAllowedValues($string, $has_data) {

      return array_combine($keys, $labels);
    }
    return $values;
  }

  /**
+1 −0
Original line number Diff line number Diff line
@@ -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();
+23 −0
Original line number Diff line number Diff line
@@ -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.');
    }
  }

}