4572 Posts in 1316 Topics by 981 members
Customising the CMS
SilverStripe Forums » Customising the CMS » ImageField stays blank
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1541 Views |
-
ImageField stays blank

20 June 2009 at 6:08am
I'd like to setup an image field for my users in a custom built page... Code pasted below after post...
When i rebuild and then launch the CMS anew and go to the page. I see all 3 new fields, placed correclty but both imagefields just stay gray! Am i missing something?
----------------------------------------------------------
class GeneralItem extends Page {
static $db = array(
"HomeLogo" => "varchar",
"MainLogo" => "varchar",
"Abstract" => "Text",
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('HomeLogo', null, null, null, null, "assets/Uploads/"), 'Content');
$fields->addFieldToTab('Root.Content.Main', new ImageField('MainLogo', null, null, null, null, "assets/Uploads/"), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Abstract'), 'Content');
return $fields;
}
} -
Re: ImageField stays blank

20 June 2009 at 6:10am
Damn, it was just the field type i had set to varchar! I changed it to text and now it works... :|
-
Re: ImageField stays blank

20 June 2009 at 6:41am
Oh well, let's continue it's not all fixed it seems...
Now that my db has been rebuilt, that i installed 2.3.2, i get this when i try to upload an image:
[Notice] Undefined index:
POST /images/index/GeneralItem/9/MainLogo/EditImageFormLine 157 in /var/www/vhosts/cobi-cdgi.com/httpdocs/sapphire/core/ClassInfo.php
What can be the cause of this?
Note: ImageField shows, i can select from the attached files on the server but when i click on attach, i get the aforementionned error....
-
Re: ImageField stays blank

3 September 2009 at 7:54pm
You need to define Images in the has_one array.
-
Re: ImageField stays blank

18 October 2009 at 12:28pm Last edited: 18 October 2009 12:28pm
Just wondering about this one too as I get the same 'UNDEFINED INDEX' error if trying to attach image from the file store. My code for this class is below:
___________________class CdPage extends Page {
static $db = array(
'Date' => 'Date',
'CdName'=> 'Text',
'CdPrice' => 'Text',
'CdAbstract' => 'HTMLText',
'CdDescription' => 'HTMLText'
);
static $has_one = array(
'CdImage' => 'Image'
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.CdInfo', new TextField('CdName'));
$fields->addFieldToTab('Root.Content.CdInfo', new TextField('CdPrice'));
$fields->addFieldToTab('Root.Content.CdInfo', new HTMLEditorField('CdAbstract'));
$fields->addFieldToTab('Root.Content.CdInfo', new HTMLEditorField('CdDescription'));
$fields->addFieldToTab('Root.Content.CdImage', new ImageField('CdCoverImage'));
return $fields;
}
}class CdPage_Controller extends Page_Controller {
}
______________I am using SS 2.3.3.
| 1541 Views | ||
|
Page:
1
|
Go to Top |

