Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Variable isn't saving

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1154 Views
  • 3pointross
    Avatar
    Community Member
    18 Posts

    Variable isn't saving Link to this post

    I am trying to setup a fairly complex site for a client, and one of the things they would like to do is be able to choose custom page color coding based on the type of product is being described on the page.

    So in the page.php I setup a drop down, and in the templates it simply appends a class change which then alters all of the css.

    Now lately, no matter how many times I change that variable on a page it fails to save... but only on some pages, not all pages? Clicking back to the page shows the dropdown on the default selection rather than the one I have changed it to.

    Here is the code below:

    class Page extends SiteTree {
       static $db = array(
       
            "PageStyle" => "Enum('Epoxy,Hardeners,Fillers,Additives,Fabrics,Mixing,Kits')"

       );
       
       static $defaults = array(
       );
       
       function getCMSFields() {
        $fields = parent::getCMSFields();
       
        $fields->addFieldToTab("Root.Content.Main", new DropdownField("PageStyle", "Style", array(
          "Epoxy" => "Epoxy",
          "Hardeners" => "Hardeners",
          "Fillers" => "Fillers",
          "Additives" => "Additives",
          "Fabrics" => "Fabrics",
          "Mixing" => "Mixing",
          "Kits" => "Kits",
          )));
       
        return $fields;
       }

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Variable isn't saving Link to this post

    rather then define that list twice you can do

    new DropdownField("PageStyle", singleton('Page')->dbObject('PageStyle')->enumValues());

    And see if that saves

  • 3pointross
    Avatar
    Community Member
    18 Posts

    Re: Variable isn't saving Link to this post

    Thanks for the suggestion, but that just turned the label to "Array" and the dropdown was then empty?

  • 3pointross
    Avatar
    Community Member
    18 Posts

    Re: Variable isn't saving Link to this post

    Any other thoughts or places to look? php.ini? mysql? database? etc?

    1154 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.