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.

Customising the CMS /

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

Data won't save to in the fields I created [Solved]


Go to End
Reply


2 Posts   1429 Views

Avatar
maryfran

Community Member, 12 Posts

15 October 2009 at 6:59am

Edited: 15/10/2009 7:40am

I created some custom fields for a promo slider on a website home page. No data will save to these fields (well, they save to the image ones but not to the text or HTMLText ones. My code is below:

class HomePage extends Page {
static $db = array(
);
static $has_one = array(
'Promo1' => 'Image',
'Promo2' => 'Image',
'Promo3' => 'Image',
'PromoText1' => 'HTMLText',
'PromoText2' => 'HTMLText',
'PromoText3' => 'HTMLText',
'PromoName1' => 'Text',
'PromoName2' => 'Text',
'PromoName3' => 'Text',
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main","Content");
$fields->addFieldToTab('Root.Content.Main', new TextField('PromoName1'));
$fields->addFieldToTab('Root.Content.Promos', new HtmlEditorField($name = "PromoText1",$title = "Promo Text 1"));
$fields->addFieldToTab('Root.Content.Promos', new ImageField('Promo1'));
$fields->addFieldToTab('Root.Content.Promos', new TextField('PromoName2'));
$fields->addFieldToTab('Root.Content.Promos', new HtmlEditorField($name = "PromoText2",$title = "Promo Text 2"));
$fields->addFieldToTab('Root.Content.Promos', new ImageField('Promo2'));
$fields->addFieldToTab('Root.Content.Promos', new TextField('PromoName3'));
$fields->addFieldToTab('Root.Content.Promos', new HtmlEditorField($name = "PromoText3",$title = "Promo Text 3"));
$fields->addFieldToTab("Root.Content.Promos", new ImageField('Promo3'));
return $fields;
}
}

Any thoughts would be helpful. The database is accepting content added to pages without my custom fields, so I know it is an issue with something I wrote...

Avatar
maryfran

Community Member, 12 Posts

15 October 2009 at 7:40am

If i had made sure the text fields were in the $db = array, I would have saved myself about 3 hours of frustration.