Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » HasManyFileManager getMyCMSFields not called

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 641 Views
  • tilluigi
    Avatar
    Community Member
    9 Posts

    HasManyFileManager getMyCMSFields not called Link to this post

    Hi there,

    we are trying to get the hasmanyfilemanager (HMFM) to work with a custom file class, but the CMS interface does not show the extra fields defined by the getMyCMSFIelds-Function in the "MyFile"-class. it seems as if the getMyCMSFields function is not beeing called at all?

    the basic HMFM works and the extra fields have been added to the database table of "File", so the decoration seems to have happened, at least on the Model side of things.

    we are using the basic example for custom file class from the HMFM-tutorial and changed the extraDBFields according to our needs. the only other difference i can see is that we are applying the HMFM to a HomePage-Class wich is subclassed from Page. Heres the MyFile-Class:

    class MyFile extends DataObjectDecorator
    {
    /**
    * Adding additional DB Fields to the File Table.
    * @see http://doc.silverstripe.com/doku.php?id=dataobjectdecorator
    *
    * @return array containing additional DB information
    */
    public function extraDBFields() {
    return array(
    'db' => array(
    'isFavorite' => 'Boolean',
    'Description' => 'Varchar(255)',
    'Category' => "Enum('photography, graphics, painting, other', 'photography')"
    )
    );
    }

    /**
    * Get the custom CMS Fields for this Class (to be used by the
    * HasManyFileManager).
    * As you can see we make a distinction between Images and other files!
    *
    * @return FieldSet
    */
    public function getMyCMSFields(){
          // trying to find out if function is being called:
          echo "TEST";
          
          if($this->owner instanceof Image){
    return new FieldSet(
                new TextField(
    'Title',
    'Title',
    $this->owner->ID ? $this->owner->Title : ''

    ),
    new TextField(
    'Description',
    'Short Description',
    $this->owner->ID ? $this->owner->Description : ''
    ),
    new DropdownField(
    'isFavorite',
    'is this a favorite?',
    array(1=> 'Yes', 0 => 'No'),
    $this->owner->ID ? $this->owner->isFavorite : 0
    ),
    new DropdownField(
    'Category',
    'Category',
    singleton('File')->dbObject('Category')->enumValues(),
    $this->owner->ID ? $this->owner->Category : 0
    )
    );
    } else {
    return new FieldSet(
    new TextField('Title', 'Title', $this->owner->Title)
    );
    }
          
    }

    }

    we are running SS 2.2.3, it seems that HMFM has only been tested with 2.2.2 and does not work with 2.3rc at all.

    anybody can help? anyone has had the same problem?

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