Jump to:

22977 Posts in 11742 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Add field to UploadField iframe

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

Page: 1
Go to End
Author Topic: 343 Views
  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Add field to UploadField iframe Link to this post

    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');

  • Naren
    Avatar
    Community Member
    21 Posts

    Re: Add field to UploadField iframe Link to this post

    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.

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Add field to UploadField iframe Link to this post

    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.

  • George Vartanov
    Avatar
    Community Member
    1 Post

    Re: Add field to UploadField iframe Link to this 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

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Add field to UploadField iframe Link to this post

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

  • kinglozzer
    Avatar
    Community Member
    138 Posts

    Re: Add field to UploadField iframe Link to this post

    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

    343 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.