Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 623551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:06:16+00:00 2026-05-13T19:06:16+00:00

I’m using Symfony 1.4 and Doctrine. Let’s say I have 2 classes : a

  • 0

I’m using Symfony 1.4 and Doctrine.

Let’s say I have 2 classes : a Brand and a Product.

When I create a new product in the Admin Generator based admin, I’d like to choose a brand from a dropdown list.
The Admin Generator is doing that for me, automatically creating a sfWidgetFormDoctrineChoice.

The problem is that the brands are ordered by id. I’d like them to be ordered by their “label” field.

In order to do that I did the following in my ProductForm class:

$this->widgetSchema['brand_id']->addOption('order_by','label');

But I get the following error:

Syntax error or access violation: 1064
You have an error in your SQL syntax;
check the manual that corresponds to
your MySQL server version for the
right syntax to use near ‘a’ at line
1. Failing Query: “SELECT b.id AS b__id, b.external_id AS
b__external_id, b.label AS b__label,
b.created_at AS b__created_at,
b.updated_at AS b__updated_at FROM
brand b ORDER BY l a”

The order by statement is really weird. I don’t understand why it seems to cut the name of the order by statement.

Edit: Apparently the ‘order_by’ option is expecting an array as a second parameter. What values does it expect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:06:17+00:00Added an answer on May 13, 2026 at 7:06 pm

    I didn’t try benlumley’s solution since he answered right when I found my solution. It seems more tedious than what I ended doing.

    I took a look at the source code to figure out how all this was working.
    It turns out the “order_by” option needs an array specifying the field on which one wants to order the results and either ‘asc’ or ‘desc’:

    $this->widgetSchema['product_id']->addOption('order_by',array('label','asc'));
    

    It works like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.