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

Add field to UploadField iframe


Reply

6 Posts   491 Views

Avatar
MarijnKampf

13 September 2013 at 3:55am Community Member, 164 Posts

I'm trying to add an additional field to the UploadField assets Edit section from SS3.0. The fields I've added are shown in the assets editor /site/admin/assets/EditForm/field/File/item/16/edit but they are not shown in the inline / iframe form of an UploadField /site/admin/pages/edit/EditForm/field/hibImages/item/16/edit.

Anyone any suggestions on what I'm missing?

Class:

class hibImage extends DataExtension {
   static $belongs_many_many = array (
      'HeaderImageBanners' => 'HeaderImageBanner'
   );
   
   function hibCroppedImage() {
      return $this->owner->croppedImage(HeaderImageBanner::$hibWidth, HeaderImageBanner::$hibHeight);
   }
   
   function random() {
      return rand();
   }

   public function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->push(new LiteralField("Literal", "<p>Test getCMSFields</p>"));
      return $fields;
   }

   // Shown
   public function updateFormFields(FieldList $fields) {
      $fields->push(new LiteralField("Literal", "<p>Test updateFormFields</p>"));
      return $fields;
   }

   public function updateCMSFields(FieldList $fields) {
      $fields->push(new LiteralField("Literal", "<p>Test updateCMSFields</p>"));
      return $fields;
   }

   public function updateFrontEndFields(FieldList $fields) {
      $fields->push(new LiteralField("Literal", "<p>Test updateFrontEndFields</p>"));
      return $fields;
   }
}

Which is added to the mysite/_config.php with:

Object::add_extension('Image', 'hibImage');

Avatar
Naren

20 September 2013 at 5:27am Community Member, 21 Posts

Hi MarijnKampf,

Please guide me a little, I have added headerimagebanner on my silverstripe site. Everything is working fine but slider is not working only one slide is visible.

Please let me know how to activate that.

Thanks in advance.

Avatar
MarijnKampf

20 September 2013 at 5:56pm Community Member, 164 Posts

Hi Naren,

Can you give me a bit more info?
1. What SS version are you running?
2. Which version of the headerimagebanner are you using?
3. How many images have you added to the slider?
4. Are you getting any getting any JavaScript errors?

Marijn.

Avatar
George Vartanov

15 November 2013 at 9:30pm Community Member, 1 Post

Hi, MarijnKampf!

Do You solve your this probblem??? I have same probblem and can't find answer. )))) Please reply me, how you solve it. Thx

Avatar
MarijnKampf

16 November 2013 at 12:02am Community Member, 164 Posts

Sorry George, I haven't been able to find a solution for this so far.

Avatar
kinglozzer

16 November 2013 at 12:51am Community Member, 146 Posts

I've achieved something similar (without using a DataExtension) in 3.1, not sure if it'll work in 3.0:

<?php

class LogoImage extends Image {

   private static $db = array(
      'ExternalURL' => 'Text'
   );

   private static $belongs_many_many = array(
      'Page' => 'Page'
   );

   /**
    * @return FieldList
    */
   public function getCMSFields() {
      $fields = parent::getCMSFields();
   
      $fields->addFieldToTab('Root.Main', new TextField('ExternalURL', 'URL'));
   
      return $fields;
   }

}

There were some changes to how the EditForm is built:

3.0: https://github.com/silverstripe/silverstripe-framework/blob/3.0/forms/UploadField.php#L842-L879
3.1: https://github.com/silverstripe/silverstripe-framework/blob/3.1/forms/UploadField.php#L1445-L1462

Hope this helps