简体   繁体   中英

Sonata Admin Bundle - Customise select field display values for nested set

I have an Entity type which uses the nested set extension. When I am accessing it within the Sonata Admin forms, it just shows up as a basic select box with no distinction between levels.

How can I force each option to be displayed using an additional '-' symbol for its level in order to help identify the nested elements.

I couldn't see a way to do this directly in the Sonata Admin Bundle but got around it by editing the model's toString method:

public function __toString() {
    return str_repeat('-', $this->lvl).' '.$this->getTitle();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM