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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

FileIFrameField not working in getCMSFields_forPopup


Go to End
Reply


3 Posts   2210 Views

Avatar
andy_steel

Community Member, 31 Posts

22 January 2009 at 11:48pm

Hi,

I'm trying to attach multiple files to a page. I'm using HasManyComplexTableField and FileIFrameField.
I get the following error on the pop-up window:

Notice: Trying to get property of non-object in C:\Projects\myproject\src\sapphire\forms\FileIFrameField.php on line 18

What am I doing wrong?

Here is my code:

<?php

class Project extends Page
{
	static $db = array(
	);

	static $has_one = array(
	);
	static $has_many = array(
		'ProjectAssets' => 'ProjectAsset',
	);

	function getCMSFields()
	{
		$fields = parent::getCMSFields();

		$tablefield = new HasManyComplexTableField(
				$this,
				'ProjectAssets',
			    'ProjectAsset',
			    array(
				    'FileTitle' => 'Title'
			    ),
			    'getCMSFields_forPopup'
		);
		$tablefield->setAddTitle('file');
		$fields->addFieldToTab( 'Root.Content.Files', $tablefield );

		return $fields;
	}
}

class Project_Controller extends Page_Controller
{
}

?>
<?php

class ProjectAsset extends DataObject {
	static $db = array(
		'FileTitle' => 'Varchar(200)'
	);
    static $has_one = array(
		'Project' => 'Project',
		'File' => 'File'		
	);
	function getCMSFields_forPopup() {
		return new FieldSet(
			new TextField('FileTitle', 'Title'),
			new FileIFrameField('File')
		);
	}
}

?>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 January 2009 at 4:16am

This is a known bug. Look at line 18 of FileIFrameField in /sapphire/forms. You'll see it's trying to access a variable that may not necessarily be defined (I believe it's called $data). Use the isset() function to determine if the variable is set before going any further.

Avatar
andy_steel

Community Member, 31 Posts

23 January 2009 at 7:32am

That fixed it. Thanks Uncle cheese!