Sort list bay label

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 24, 2012   (RSS)

By theclicklab - July 24, 2012

Hi there, I have a dropdown list that defaults to sort by value. How do I change this to sort by label?

Example code:
<?php

$schema = loadSchema('product_database');
$fieldSchema = $schema['category'];
$fieldOptions = getListOptionsFromSchema($fieldSchema);

foreach ($fieldOptions as $valueAndLabel) {
list($value,$label) = $valueAndLabel;
$encodedValue = htmlspecialchars($value);
$encodedLabel = htmlspecialchars($label);
print "<option value=\"$encodedValue\">$encodedLabel</option>\n";
}
?>


Thanks