Verified Commit ec845279 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3251647 by dsdeiz, phenaproxima, joachim: Field mapping options in...

Issue #3251647 by dsdeiz, phenaproxima, joachim: Field mapping options in media type form are not sorted correctly

(cherry picked from commit b3d036aa)
(cherry picked from commit 93a3045f)
parent a7d6ac0c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public function form(array $form, FormStateInterface $form_state) {
        }
      }

      natcasesort($options);

      $field_map = $this->entity->getFieldMap();
      foreach ($source->getMetadataAttributes() as $metadata_attribute_name => $metadata_attribute_label) {
        $form['source_dependent']['field_map'][$metadata_attribute_name] = [
+7 −0
Original line number Diff line number Diff line
@@ -102,6 +102,13 @@ public function testMediaTypeCreationFormWithDefaultField() {
    $assert_session->fieldDisabled('Media source');
    $assert_session->pageTextContains('The media source cannot be changed after the media type is created.');

    // Check that the field map options are sorted alphabetically.
    $options = $this->xpath('//select[@name="field_map[attribute_1]"]/option');
    $this->assertGreaterThanOrEqual(3, count($options));
    $this->assertSame('- Skip field -', $options[0]->getText());
    $this->assertSame('Name', $options[1]->getText());
    $this->assertSame('Test source', $options[2]->getText());

    // Open up the media add form and verify that the source field is right
    // after the name, and before the vertical tabs.
    $this->drupalGet("/media/add/$mediaTypeMachineName");