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, biapar, Willr, Ingo

Uploading a PDF file in the CMS Popup for a DataObject


Go to End
Reply


4 Posts   1626 Views

Avatar
Andrew Houle

Community Member, 134 Posts

5 December 2008 at 4:51am

I would like to have an upload file field in my CMS Popup for my Programs DataObject. So that the user can add a single PDF file for each program. I am able to get the field to show and browse my computer, but when I click save the loader just spins. I can't find much of any documentation on this sort of thing, but I think it's fairly easy to accomplish and I'm just missing a step. Here is my code:

<?php

class Programs extends DataObject {
	
	static $db = array(
		'Program' => 'Text',
		'Link' => 'Varchar',
		'MyCollegesID' => 'Decimal',
	);
	
	static $has_one = array(
		'CurriculumCard' => 'File',
		'Department' => 'Departments',
		'Colleges' => 'MyColleges'
	);
	
	function getCMSFields_forPopup() {
		$fields = new FieldSet();
		$fields->push( new TextField( 'Program' ) );
		$fields->push( new TextField( 'Link' ) );
		$fields->push( new FileField( 'CurriculumCard' ) );
		
		$ctype = DataObject::get("Colleges");
  		$map = $ctype->toDropDownMap('ID', 'College');
   		$fields->push( new DropdownField('CollegesID','College',$map)); 
		
		return $fields;
	}	
	
}

?>

Thanks in advance for your help!

Avatar
Carbon Crayon

Community Member, 598 Posts

5 December 2008 at 4:55am

Hi Andrew

I always use a FileIFrameField for that sort of thing, seems to work fine. Haven't tried using the FileField so cant comment on that.

Avatar
Andrew Houle

Community Member, 134 Posts

5 December 2008 at 5:07am

That works perfect! Thanks so much!

Avatar
Carbon Crayon

Community Member, 598 Posts

5 December 2008 at 5:08am

no probs, glad I could help! :)