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:

Form Questions /

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

problems saving date data - CompositeDateField


Go to End


3 Posts   2474 Views

Avatar
danzzz

Community Member, 175 Posts

22 September 2009 at 12:43am

Edited: 22/09/2009 12:44am

hi again,

I'm using model admin and now can insert rows in the backend. I defined also this field:

"Geburtsdatum" => "Date"

im my $db array.

the backend form ask me for this field with a simple input field.

but in the frontend I replace the field:

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

so I have a better input format (3 dropdowns).

the problem now is, the date dont't loads ($form->loadDataFrom) into the 3 dropdown fields
and I also can't update the date from the frontend form.

what could be the problem here?

thx
daniel

Avatar
Sam

Administrator, 690 Posts

22 September 2009 at 9:34am

Where did you put that code snippet?

Avatar
danzzz

Community Member, 175 Posts

22 September 2009 at 6:37pm

hi sam,

I extend the Member class and put it in the getFrontendFields function:

            public function getFrontendFields() {
		$fields = $this->scaffoldFormFields(array(
			'restrictFields' => array(
				'Anrede',
				'FirstName',
				'Surname',
				'Ort',
				'Email',
				'Geburtsdatum',
			),
			'fieldClasses' => array(
				'Email' => 'EmailField',
			)
		));
		
		$fields->changeFieldOrder(array(
			'Anrede',
			'FirstName',
			'Surname',
			'Ort',
			'Email',
			'Geburtsdatum'
		));
		
		$geburtsdatum = new CompositeDateField(
			'Geburtstag',
			'Geburtstag (Tag, Monat, Jahr)','','1910-2009'
		);
		
		$fields->replaceField('Geburtsdatum',$geburtsdatum);
		
		return $fields;
	
	}

daniel