Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Order tags alphabetically #246

Closed
lucasgranberg opened this issue Jun 2, 2015 · 6 comments
Closed

Order tags alphabetically #246

lucasgranberg opened this issue Jun 2, 2015 · 6 comments

Comments

@lucasgranberg
Copy link

I can't seem to find a way to order the tags in the select2 dropdown. I would like to use doctrines order-by mappin, like this.

<order-by>
    <order-by-field name="name" direction="ASC" />
</order-by>

I tried using the association override in my easyextended newsbundle like this:

<association-overrides>
    <association-override name="tags">
        <order-by>
            <order-by-field name="name" direction="ASC" />
       </order-by>
   </association-override>
</association-overrides>

but it doesnt work, I get the following error.

Invalid field override named 'tags' for class 'Application\Sonata\NewsBundle\Entity\Post

I suspect it is becouse of the mapping being done in the dependencyinjector but Im not sure in what order the different configurations are used.

Anyway I suppose ordering by name should be the default, maybe it could be done from sonata admin or via javascript but it seems logical to me that ordering by name would be the default.

@sagikazarmark
Copy link
Contributor

👍

@OskarStark
Copy link
Member

👍 , but I'm not so familar with the NewsBundle

anyone willing to provide a PR?

@sagikazarmark
Copy link
Contributor

Actually I would solve this issue at the Admin level. I wouldn't add this ordering right into the Entity. AFAIK you can create custom queries in the admin form mapper (even for relations). Tags should be sorted there in a custom query.

@OskarStark
Copy link
Member

I would solve this on Entity-Level because you want the same ordering in the frontend, right?

@sagikazarmark
Copy link
Contributor

Not necessarily. For example you could order tags by the highest number of posts under a specific tag. Or most popular tag based on views. Personally I think that the less logic in entities, the better it is.

@OskarStark
Copy link
Member

Let’s keep it like it is

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants