symfony - Group tasks by their priority with Twig and Symfony2? -


i have 2 entities task , taskpriority, relations work.

i want show task order priority that:

urgent
- task #1
- task #3
- task #8

todo
- task #2
- task #4
- task #7

i tried that, know can't work shows want do:

{% priority in tasks.priority %}     <div class="col-md-12">         <div class="panel panel-default">             <div class="panel-heading">                 <i class="glyphicon glyphicon-exclamation-sign"></i>{{ priority.title }}             </div>              <ul class="list-group">                 <li class="list-group-item">                     {{ task.title }}                 </li>             </ul>         </div>     </div> {% endfor %} 

what's correct way that?

edit

i have methods in taskrepository:

class taskrepository extends entityrepository {     public function graball()     {         $querybuilder = $this->createquerybuilder('t')             ->leftjoin('t.category', 'c')->addselect('c')             ->leftjoin('t.user', 'u')->addselect('u')             ->leftjoin('t.project', 'p')->addselect('p')             ->orderby('t.id', 'desc');          return $querybuilder->getquery()->getresult();     }      public function findfiltereditems($users, $categories, $projects, $search)     {         $querybuilder = $this->createquerybuilder('t')             ->leftjoin('t.user', 'u')->addselect('u')             ->leftjoin('t.category', 'c')->addselect('c')             ->leftjoin('t.project', 'p')->addselect('p')             ->orderby('t.id', 'desc');          if($users) {             foreach($users $id) {                 $querybuilder->orhaving('u.id = :id')->setparameter('id', $id);             }         }          if($categories) {             foreach($categories $id) {                 $querybuilder->orhaving('c.id = :id')->setparameter('id', $id);             }         }          if($projects) {             foreach($projects $id) {                 $querybuilder->orhaving('p.id = :id')->setparameter('id', $id);             }         }          if($search) {             $querybuilder->orwhere('t.title :search')->setparameter('search', $search);         }          return $querybuilder->getquery()->getresult();     } } 


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -