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, simon_w

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


Reply


3 Posts   503 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!!! :)