Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [polls] SS 2.4 PollChoices DataObjectDecorator

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

Page: 1
Go to End
Author Topic: 333 Views
  • Imploosio
    Avatar
    Community Member
    5 Posts

    [polls] SS 2.4 PollChoices DataObjectDecorator Link to this post

    Hi,

    I'm using SilverStripe 2.4 and the latest polls module to create and manage a simple multiple choice poll on my site. What I'm trying to do, is to extend the poll choices to have couple extra fields such as an image per choice. Pretty simple stuff, just can't figure out how to get the fields to show up in admin. Here's what I have so far:

    PollChoiceDecorator.php

    class PollChoiceDecorator extends DataObjectDecorator {
    function extraStatics() {
    return array(
    'db' => array(
    'URL' => 'Varchar',
    ),
    'has_one' => array(
    'Image' => 'Image',
    ),
    );
    }

    public function getCMSFields() {
    $this->extend('updateCMSFields', $fields);
    return $fields;
    }

    public function updateCMSFields(FieldSet $fields) {
    $fields->push(new TextField('URL', 'URL address'));
    $fields->push(new FileIFrameField('Image', 'Choice image'));
    }
    }

    _config.php

    // Extend PollChoice
    Object::add_extension('PollChoice', 'PollChoiceDecorator');

    The fields show up in db, but I can't get them to show up in the popup for a single choice. What am I doing wrong here? Is this even the right way to do this?

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