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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

custom Field for the UploadField created in DataExtension does not show up


Go to End


628 Views

Avatar
Benschli

Community Member, 1 Post

4 October 2014 at 12:06pm

Hello,

i need some help for a problem i can't solve. I'm banging my head on the table allready and this hurts my head and my ego ;)

I tried to create a simple DropdownField feeded from an Enum as a DataExtension.

class ProjectImage extends DataExtension {
    static $db = array(
        "ImageSizeInGrid" => "Enum('Fullsize, Onecolumn, Twocolumns', 'Fullsize')"
    );

    public function sizeInGrid() {
        $fields = $this->owner->getCMSFields();

        $newField = new DropdownField('ImageSizeInGrid', 'ImageSizeInGrid', $this->owner->dbObject('ImageSizeInGrid')->enumValues());
        $fields->addFieldToTab('Root.Main', $newField);

        return $fields;
    }
}

i registered the DataExtension in my _config file:

Object::add_extension('File', 'ProjectImage');

and in my ProjectPage i have something like this:

public static $many_many = array(
        'Images' => 'Image'
);

public function getCMSFields() {
        $fields = parent::getCMSFields();
        $imageField = new UploadField('Images', 'Portfolio images');

        $imageField->setConfig('fileEditFields', 'sizeInGrid');
        $fields->addFieldToTab('Root.Images', $imageField);
}

I flushed backend and frontend several times after i /dev/build the site. In the Database the table "File" has the custom created Enum Field with the right default value, but i can't get the dropdown to show up in the edit form. I then tried it with a simple text field, but it did not work either. As far as i can see, there are no error messages at all and the UploadField is working as it should, but without he custom field.

Can someone point me in the right direction, how i can create some custom fields for the UploadField?

Thank you very much and kind regards