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.

Archive /

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

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

Variable isn't saving


Go to End


4 Posts   1451 Views

Avatar
3pointross

Community Member, 19 Posts

2 September 2008 at 1:07am

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;
}

Avatar
Willr

Forum Moderator, 5523 Posts

2 September 2008 at 9:47am

rather then define that list twice you can do

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

And see if that saves :D

Avatar
3pointross

Community Member, 19 Posts

3 September 2008 at 1:58am

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

Avatar
3pointross

Community Member, 19 Posts

4 September 2008 at 10:20am

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