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.

Archive /

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

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

Problem with the FileField type.


Go to End
Reply


3 Posts   3081 Views

Avatar
mlaprise

Community Member, 3 Posts

27 August 2008 at 10:42am

Hi everyone,

I have some problem with the FileField type. I want to have a link to a single doc file, here is the code:

class DocumentPage extends Page 
{
	static $db = array(
		'Auteur' => 'Text',
		'ResumeCourt' => 'Text'
	);
	
	static $has_one = array(
		'lienDocument' => 'FileIFrameField'
	);
	
	   	
	function getCMSFields()
	{
		$fields = parent::getCMSFields();
     		$fields->addFieldToTab('Root.Content.Main', new TextareaField('Auteur', 'Auteur(s)'), 'Content');
     		$fields->addFieldToTab('Root.Content.Main', new TextareaField('ResumeCourt', 'Resume Court'), 'Content');
		$fields->addFieldToTab('Root.Content.Document', new FileIFrameField('lienDocument', 'Selectionner votre document'));
		
		return $fields;
	}
}
 
class DocumentPage_Controller extends Page_Controller
{

}
 

When I edit the page in the admin section I get the following error message:

Fatal error: Class 'FileIFrameField ' not found in /var/www/sapphire/core/model/DataObject.php on line 921

I tried to use the FileField type instead and it seem to work. The Browse... button appear in the interface but there is no Upload button. Did I missed something ?

Thank for you help !

PS: Silverstripe is VERY nice ! By far the best CMS/platform around !

Avatar
Willr

Forum Moderator, 5521 Posts

27 August 2008 at 3:28pm

Your database type needs to be of type 'File' rather then 'FileIFrameField' Even though the Field in the CMS you want is a FileIFrameField you want to save that data into a database type of File.

   static $has_one = array( 
      'lienDocument' => 'File' 
   ); 
    

Avatar
mlaprise

Community Member, 3 Posts

28 August 2008 at 1:30pm

ye...right...it work now ! :-)

Thanks !