Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Handle Enum values in FormAction Problem

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

Page: 1
Go to End
Author Topic: 1747 Views
  • stefant42
    Avatar
    Community Member
    14 Posts

    Handle Enum values in FormAction Problem Link to this post

    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?

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Handle Enum values in FormAction Problem Link to this post

    Maby you missed some quotation marks:

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

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Handle Enum values in FormAction Problem Link to this post

    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

    1747 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.