how are you all guys?
I want to sort(in ascending or descending order) a form fields through generator.yml in symfony. I mean I have 2 tables Events and Members. Relation between these two tables are many to many. What I want is that when I go to add/edit an event, members list should be sorted b开发者_如何学Goy their names.
I tried to use:
config:
      actions: ~
      fields:
        title:           { help: Title of the event ,label: Event Name *}
        event_datetime:  { help: Set the date and time of event ,label: Date time *}
        details:   { help: Details related to event ,label: Details *}
        venue_id:           { help: Select venue }
        is_visible:   { help: Select is visible or not}
        members_list:           { help: List of members }
        slug: { help: User Friendly URL,label: User Friendly URL }
      sort: [mmebers_list, asc]
But it does not work successfully. any suggestion please?
Thanks
Try Adding this to your schema.yml
Member:
  actAs:
    Timestampable:
    Sluggable:
      unique: true
      fields: [name]
      canUpdate: true
  options:
    orderBy: name ASC
This will sort all the members lists globally in your application
I had a similar problem, but I use sfGuardUser plugin and I don't want to change their schema. I had to change action files and add:
public function executeNew(sfWebRequest $request)
{
    parent::executeNew($request);
    $sql = Doctrine_Query::create()->from('sfGuardUser u')->innerJoin("u.Profile p")->where('u.is_super_admin = ?',false)->orderBy('p.lastname');
    $this->form->getWidget('user_id')->setOption('query',$sql);
}
You need to pass query which symfony use to get data to field.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论