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.

Archive /

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

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

ComplexTableFields and "MyName"

Go to End

3 Posts   1689 Views


Community Member, 25 Posts

8 December 2008 at 4:12pm

In the documentation for CTFs, they're all shown as using a parameter "MyName" (which goes where the relation name would go).

I'm modifying the CMS and trying to get different Page Types to show different CTFs. Each Page Type has its own class which extends Page, and it's pulling in only one table with no relations, which has its own class which extends DataObject.

BandMembers.php - table


class BandMembers extends DataObject
	public static $db = array
		'BandFirstName'			=>	'Text',
		'BandFamilyName'		=>	'Text',
		'BandInstruments'		=>	'Text',
		'BandMemberBlurb'		=>	'Text'

	public static $has_one = array();

class BandMembers_Controller extends ContentController

AboutPage.php - About Page page type
class AboutPage extends Page

	##	Set up the database

	static $db = array
		'BackgroundTitle'			=>	'Text',
		'BackgroundContent'			=>	'HTMLText',
# Some more DB fields here, no name clashes or anything

	function getCMSFields()
		$fields = parent::getCMSFields();

		# Create Band Member management tab
		$showMembers = new ComplexTableField(
				'BandFirstName' => 'Forename',
				'BandFamilyName' => 'Surname',
				'BandInstruments' => 'Instrument(s)'
			new FieldSet(
				new TextField('BandFirstName', 'Forename'),
				new TextField('BandFamilyName', 'Surname'),
				new TextField('BandInstruments', 'Instrument(s)'),
				new HTMLEditorField('BandMemberBlurb', 'Band Member Blurb')


		$fields->addFieldToTab('Root.Content.BandMembers', $showMembers);
		return $fields;

The problem is I can only use "MyName" as a parameter for one Page Type like this - other Page Types using MyName will pull in this form. Using anything else gives a error of "I can't handle sub-URLs of a ... object" (Form, in this case).

The member Dig here says he fixed it here:
"EDIT: I fixed it, I was being too clever and not constructing the full form if it wasn't being requested for displaying. Basically any path the exits early before creating the full form with the ComplexTableField in it will break it. Makes sense when you think about it!"

I'd try to return a form, except I have to return a FieldSet for getCMSMethods.

Any suggestions on how I can fix it to allow multiple CTFs with different tables?

Each CTF only needs to show data from one table.

Thanks in advance :)


Community Member, 25 Posts

10 December 2008 at 6:58am

Does anyone have any thoughts on how I could get this working?


Community Member, 25 Posts

11 December 2008 at 1:15pm

Anybody at all? :) Would be really handy if someone could give me some ideas.