5099 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 594 Views |
-
Backend inputs won't be saved... at least not all

25 January 2010 at 8:39pm Last edited: 25 January 2010 8:39pm
Hi,
I extended the backend with a new Main.Teaser tab and created an ImageField, two TextFields and and a SiteTree DropDown. Perfectly working are the Image and the DropDown. The TextFields are shown, but the data cannot be saved, that means, you can write text in it, can save the site, get a positive feedback "Your site has been saved.", but when you reload the backend site, the information is gone... Strange, isn't it?
Here is my code:
class TeaserContentCombo extends Page {
static $db = array();
static $has_one = array(
'TeaserPhoto' => 'Image',
'TeaserTitle' => 'Text',
'TeaserContent' => 'Text',
'TeaserTarget' => 'SiteTree'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldsToTab(
"Root.Content.Teaser",
array(
new ImageField('TeaserPhoto'),
new TextField('TeaserTitle'),
new TextField('TeaserContent'),
new TreeDropdownField("TeaserTargetID", "Choose a site to be forwarded to:", "SiteTree")
)
);
return $fields;
}
}class TeaserContentCombo_Controller extends Page_Controller {
}Thanks a ton for every help in advance!
Cheers, Mario
-
Re: Backend inputs won't be saved... at least not all

26 January 2010 at 2:20pm Last edited: 26 January 2010 2:24pm
Ah... you got me there: staring and staring at your code...
But actually it is quite simple.
Both TeaserTitle and TeaserContent should be in the $db-array since Text is a data-type on the TeaserContentCombo-table.Instead of being a data-type, Image and SiteTree mean that TeaserPhoto and TeaserTarget are establishing a relationship with either the Image- and the SiteTree-table (same for $has_many and $many_many).
In general: all data-types should be in the $db-array, all relationships in $has_one, $has_many and $many_many.
For more on data-types, please read the docs.
For more on relationships, please read the fifth tutorial -
Re: Backend inputs won't be saved... at least not all

26 January 2010 at 8:55pm
Thanks! Thanks! Thanks!
I found that out by myself, but I was hoping, that someone will give me an explanation about why. And you did this perfect! Thank you!
Cheers, Mario
| 594 Views | ||
|
Page:
1
|
Go to Top |


