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:

Data Model Questions /

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

getFrontendFields - ordering the fileds


Go to End


2 Posts   3155 Views

Avatar
danzzz

Community Member, 175 Posts

17 September 2009 at 8:11pm

hi there,

I have this function to generate a registration form:

public function getFrontendFields() {
	$fields = $this->scaffoldFormFields(array(
		'restrictFields' => array(
			'Anrede',
			'FirstName',
			'Surname',
			'Email',
			'Geburtsdatum',
		),
		'fieldClasses' => array(
			'Email' => 'EmailField',
		)
	));
	
	return $fields;
	
}

so, first problem:
on the page the ordering of the fields is not the same, the ordering is:

FirstName,
Surname,
Email,
Anrede (Salutation in German),
Geburtsdatum (Birthday in German)

how can I order the fields? for example the salutation should be on first place :-)

next question:

how can I implement a CompositeDateField for my birthday field?
If I would generate a normal form I would use:

$geburtsdatum = new CompositeDateField(
	'Geburtstag',
	'Geburtstag (Tag, Monat,Jahr)','','1910-2009'
);

how can I implement this into my getFrontendFields Code?

thanx

Daniel

Avatar
danzzz

Community Member, 175 Posts

21 September 2009 at 12:16am

hi,

I have the solution ... (thx 2 ajshort from silverstripe irc channel)

field ordering:

$fields->changeFieldOrder(array(
			'Anrede',
			'FirstName',
			'Surname',
			'Email',
			'Geburtsdatum'
		));

replaceing fields:

$geburtsdatum = new CompositeDateField(
			'Geburtstag',
			'Geburtstag (Tag, Monat, Jahr)','','1910-2009'
		);
		
		$fields->replaceField('Geburtsdatum',$geburtsdatum);

daniel