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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Handle Enum values in FormAction Problem


Go to End


3 Posts   2790 Views

Avatar
stefant42

Community Member, 14 Posts

15 February 2010 at 2:57am

Hi all,

i have some stupid Problem using an Enum field.

	static $db = array(
		'MultimediaGalerieDummy' => 'Varchar(1)',
		'GalerieTyp' => "Enum('Popup, Slider', 'Popup')",
		'VorschauTyp' => "Enum('Kompakt, Detail', 'Kompakt')",
	);

.....
	public function doGalerieOptionsForm($data, Form $form) {
		/* Werte setzen */
		$this->GalerieTyp = $data["GalerieTyp"];
		$this->VorschauTyp = $data["VorschauTyp"];

		$this->write();
		$this->doPublish();
....

The values become not saved. Why?

Avatar
baba-papa

Community Member, 279 Posts

15 February 2010 at 12:44pm

Maby you missed some quotation marks:

      'GalerieTyp' => "Enum('Popup', 'Slider', 'Popup')", 
      'VorschauTyp' => "Enum('Kompakt', 'Detail', 'Kompakt')

Avatar
swaiba

Forum Moderator, 1899 Posts

6 August 2010 at 4:00am

Hi,

I disagree I just tried your method baba-papa for an enum that works perfectly well and got an error...

		'Sevirty' => "Enum('High,Medium,Low','Medium')",//original
		'SevirtyTwo' => "Enum('High','Medium','Low','Medium')",//bab-papa

"The default value 'Medium' does not match any item in the enumeration"

(and yes removing 'SevirtyTwo' makes it all work fine)

I'd say your problem is elsewhere, stefant42, maybe you have a onBeforeWrite, validator or something else?

Barry