You need to make the dropDownList have a tree type list
Category1
--Category1.1
--Category1.2
Category 2 ....
There is a code that forms this list, but in it I can only select a subcategory, but the main one cannot.
So the question is how to make it so that you can choose the first category.
Listing category search method
public static function getHierarchy() { $options = []; $parents = self::find()->where("parent_id=0")->all(); foreach ($parents as $id => $p) { $children = self::find()->where('parent_id=:parent_id', ['parent_id' => $p->id])->asArray()->all(); $child_options = []; foreach ($children as $child) { $child_options[$child->id] = $child->name; } $options[$p->name] = ArrayHelper::map($children, 'id', 'name'); } return $options; } 
<optgroup>if I’m not mistaken, that’s why it’s impossible to choose it ... You<optgroup>rather need to use styles to implement this. - Roman Grinyov