In the function webform_components, the components are sorted by key. When working in an other language than English, the order seems weird because it's not alphabetical.

The patch attached, sorts the components by the label that is shown in the select list.

CommentFileSizeAuthor
sort_components_alphabetically.patch973 bytesjeroent

Comments

  • DanChadwick committed 50e35ca on 7.x-4.x
    Issue #2412119 by JeroenT, DanChadwick: Added Sort components...
  • DanChadwick committed 2d1c51c on 8.x-4.x
    Issue #2412119 by JeroenT, DanChadwick: Added Sort components...
danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Needs review » Fixed

Nice. I simplified your code a touch. We require PHP 5.3, so we have anonymous functions. The testing for the presence of 'label' isn't needed as other code assumes it is defined. To not define it would be a bug in the component.

    uasort($components, function($a, $b) {
      return strnatcasecmp($a['label'], $b['label']);
    });

I doubt the "natural" part will ever matter, because component labels would not normally have digits. But I don't see the harm.

Committed to 7.x-4.x and 8.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.