Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Ambiguous fields in ComplexTableField

Go to End



Community Member, 13 Posts

3 October 2008 at 1:11am

Hi there,

I have extended the ComplexTableField to administer ecommerce orders, however on joining the Member table (in the join parameter for ComplexTableField) and trying to filter the results a nice ajax error is returned.

What i am trying to do is show the Order ID, Customer Surname, Order Status, Created Order Date and Last Updated Order Date.

Ajax error below:

Could not filter results: ERROR:Error 256: DATABASE ERROR: Couldn't run query: SELECT `Order`.*, `Order`.ID, if(`Order`.ClassName,`Order`.ClassName,'Order') AS RecordClassName, Surname, Status, Created FROM `Order` LEFT JOIN `Member` ON `Order`.`MemberID` = `Member`.`ID` WHERE (`Member`.`Surname` LIKE '%culs%') GROUP BY `Order`.ID | Column 'Created' in field list is ambiguous At l431

The code i'm actually using here is (ComplexTableField Extension):

function __construct($controller, $name, $sourceClass, $mode, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "") {
		$this->mode = $mode;
		parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
		$this->Markable = true;
		// search
		$search = isset($_REQUEST['TransactionSearch']) ? Convert::raw2sql($_REQUEST['TransactionSearch']) : null;
		if(!empty($_REQUEST['TransactionSearch'])) {
			$this->sourceFilter[] = "`Member`.`Surname` LIKE '%$search%'";

and the actual calling function

$tableFields = array(
			"ID" => _t('TransactionAdmin.ORDERNO', 'Order Number'),
			"Surname" => _t('TransactionAdmin.SURNAME', 'Surname'),
			"Status" => 	_t('TransactionAdmin.STATUS', 'Status'),
			"Created" => _t('TransactionAdmin.CREATED', 'Created')
		// Options for drop down field
		$options['Unpaid'] = 'Unpaid';
		$options['Paid'] = 'Paid';
		$options['Query'] = 'Query';
		$options['Processing'] = 'Processing';
		$options['Sent'] = 'Sent';
		$options['Complete'] = 'Complete';
		$options['MemberCancelled'] = 'MemberCancelled';
		$options['AdminCancelled'] = 'AdminCancelled';
		$popupFields = new FieldSet(
			new DropdownField("Status", _t('TransactionAdmin.STATUS', 'Status'),$options),
			new CheckboxField("Printed", _t('TransactionAdmin.PRINTED', 'Mark as Printed'))
		$idField = new HiddenField('ID', '', $section);
		$table = new TransactionTableField($this, "Order", "Order", $section, $tableFields, $popupFields, ((isset($filter))?array($filter):array()), null, "LEFT JOIN `Member` ON `Order`.`MemberID` = `Member`.`ID`"); //array($filter)
		$fields = new FieldSet(
			new TabSet(	'Root',
				new Tab(_t('TransactionAdmin.ORDERS', 'Orders'),
					new LiteralField("Title", $title),

btw i know the TransactionTableField() function caller is a bit dailywtf :)

Thanks in advance