If you are using Admin Generator in Symfony 1.4, you might encounter a problem where the drop down list is not in order. Many friends ask me how to sort the drop down list that generated by Admin Generator, here i’ve this post to share the way to all of them 🙂
To sort drop down list that generated by Admin Generator follow the steps below:-
Advertisements
- Open your form class in lib/form/doctrine/base/BasexxxxForm.class.php
- look for the $this->setWidgets array for your drop down field
- and add ‘order_by’ => array(‘name’, ‘asc’) to the last array. Refer to the example below:-
'category_id' => new sfWidgetFormDoctrineChoice( array( 'model' => 'MyCategory', 'add_empty' => true, 'order_by' => array('name', 'asc') ) ),
** of course, you need to replace the ‘name’ to the field that you want to sort
- Once you save your modification, now do a clear cache at your application and reload your form
- You Should see the drop down list is being sorted now 🙂
Happy coding.
Related posts:
Debian: "There is no public key available for the following key IDs"
Prestashop 1.6: "Unexpected token <" error when upload category thumbnail
How to setup syslog server in UBuntu 8
Mod Security - Open source Web Application Firewall
How to re-arrange account order in Thunderbird
Symfony Filter: Change ForeignKey drop down to Text field
MySQL 5.5 PDO::__construct(): The server requested authentication method unknown to the client [mysq...
Free FTP Client for Mac OS X / Win XP / Vista
Share this with your friends:-