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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

File edit/delete buttons dissapear in multiple files uploadfield after 'save & publish'


Go to End


3 Posts   913 Views

Avatar
Friksel

Community Member, 7 Posts

30 October 2012 at 9:29pm

Hi Silverstripers,

Somehow I can't find a way to get thisone working;

I extended Page with a has_many relation to multiple Files and overwritten getCMSFields to show an uploadfield in the CMS.
I use Silverstripe 3.02.

Everything looks fine in the CMS; users can upload one or more files on this page and the upload field automaticaly expands to handle more files to upload. All files have an edit- and an delete-button next to it. But somehow these buttons magicaly dissapear when the user saves & publishes the page. And they never come back.... :(

I looked everywhere on Google, but can't find anybody having the same problem.

A solution or workaround to this problem is highly appreciated!!
Anybody?

This is my code:

class pageWithDocs extends Page {
	static $has_many = array(
		'AttachedDocuments' => 'File'
	);
 
	public function getCMSFields() {
		$fields = parent::getCMSFields();

		$fields->addFieldToTab('Root.Main', new UploadField('AttachedDocuments', 'Documenten', $this->AttachedDocuments()));
				
		return $fields;
	}
}

Avatar
copernican

Community Member, 189 Posts

1 November 2012 at 8:27am

Try changing your relationship from a $has_many to a $many_many. I know it doesn't really make sense but it seemed to help me when i was having issues with UploadField. don't forget to /dev/build!

Avatar
Friksel

Community Member, 7 Posts

1 November 2012 at 11:40pm

That was it! Thanks a lot IOTI!!! :)