Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Uploading a PDF file in the CMS Popup for a DataObject

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

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

Page: 1
Go to End
Author Topic: 1387 Views
  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Uploading a PDF file in the CMS Popup for a DataObject Link to this post

    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!

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Uploading a PDF file in the CMS Popup for a DataObject Link to this post

    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.

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: Uploading a PDF file in the CMS Popup for a DataObject Link to this post

    That works perfect! Thanks so much!

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Uploading a PDF file in the CMS Popup for a DataObject Link to this post

    no probs, glad I could help!

    1387 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.