I want to add small image to my slider in CMS. Currently what I have down here works for me, I have one big Image:
class Banner extends SortableObject {
private static $db = array(
);
private static $has_one = array(
'HomePage' => 'HomePage',
'Image' => 'Image',
'Target' => 'Page',
);
private static $summary_fields = array(
'ID',
'Target.MenuTitle',
);
public function getCMSFields() {
$fields = new FieldList();
$img = new UploadField('Image');
$img->setFolderName('hpbanners');
$img->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
$fields->push($img);
$drop = new TreeDropdownField('TargetID','Choose page','SiteTree');
$fields->push($drop);
return $fields;
}
}
Now I want to add another field. I added $smallImage
, as I understand this should add new column in DB, just like Image before, but my problem is that in DB table I have only first image, second is not added:
class Banner extends SortableObject {
private static $db = array(
);
private static $has_one = array(
'HomePage' => 'HomePage',
'Image' => 'Image',
'SmallImage' => 'SmallImage',
'Target' => 'Page',
);
private static $summary_fields = array(
'ID',
'Target.MenuTitle',
);
public function getCMSFields() {
$fields = new FieldList();
$img = new UploadField('Image');
$img->setFolderName('hpbanners');
$img->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
$fields->push($img);
$smallImage = new UploadField('SmallImage');
$smallImage->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
$fields->push($smallImage);
$drop = new TreeDropdownField('TargetID','Choose page','SiteTree');
$fields->push($drop);
return $fields;
}
}
So please tell me, as I know this column will be automatically added, should I clear cache or what am I doing wrong? Help me! :)