How to sort a dropDownList

Hi all,

my dropDownList with data from the related parent table works, but it’s sorted by id, not by the attribute name.


<?= $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(parenttable::find()->all(), 'id', 'name'))  ?>

How to sort this by name?

ModelClass::find()->orderBy("name DESC")->all()

read the docs before asking

Thanks. I read the docs but couldn’t find it. Searched in the wrong class. Sorry for asking.

class is ActiveQuery