You can find available options for the sfWidgetFormDoctrineChoice
here
* model: The model class (required)
* add_empty: Whether to add a first empty value or not (false by default)
If the option is not a Boolean, the value will be used as the text value
* method: The method to use to display object values (__toString by default)
* key_method: The method to use to display the object keys (getPrimaryKey by default)
* order_by: An array composed of two fields:
* The column to order by the results (must be in the PhpName format)
* asc or desc
* query: A query to use when retrieving objects
* multiple: true if the select tag must allow multiple selections
* table_method: A method to return either a query, collection or single object
You can use the order_by
option like this: ...->setOption('order_by', array('some_field', 'asc'))
.
UPDATE:
If you want to order by multiple fields you can write a custom query and add multiple order by to it and then use the query
or table_method
option instead of order_by
.
E.g. (you should write the query into a table class instead):
$query = Doctrine_Core::getTable('UserTable')->createQuery('u')->orderBy('u.last_name asc, u.first_name asc');
$this->getWidget('user_id')->setOption('query', $query);
// if you add some where condition to the query
// don't forget to set it to the validator as well
$this->getValidator('user_id')->setOption('query', $query);