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.

Data Model Questions /

Handle Enum values in FormAction Problem


Reply


3 Posts   1761 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, 1798 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