Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TreeDropDownField in Widgets - CMS error #2906

Open
ellecarrier opened this Issue · 4 comments

4 participants

@ellecarrier

I'd like to set a Linked Page from within a Widget in the CMS...

Using the following in getCMSFields()

TreeDropdownField::create('LinkedPageID', 'LinkedPage', 'SiteTree')

Is causing this error:

Fatal error: Call to a member function FormAction() on a non-object in /public_html/framework/forms/FormField.php on line 161

Any ideas?

I've used the same kind of code outside of widgets, in pages, and of course is works fine.

Thanks
Sean

@kmayo-ss

What version of CMS and framework are you using

@kmayo-ss

Tried the following code on the latest version of CMS and framework which is 3.13 and it worked OK for me.
Would you be able to provide us with the code you are using?

<?php
class Page extends SiteTree {

        private static $db = array(
                'LinkedPageID' => 'Int'
        );

        private static $has_one = array(
        );


        public function getCMSFields() {
                $fields = parent::getCMSFields();
                $linkedPage = TreeDropdownField::create('LinkedPageID', 'LinkedPage', 'SiteTree');
                $fields->push($linkedPage);
                return $fields;
        }       

}
class Page_Controller extends ContentController {

        /**
         * An array of actions that can be accessed via a request. Each array element should be an action name, and the
         * permissions or conditions required to allow the user to access it.
         *
         * <code>
         * array (
         *     'action', // anyone can access this action
         *     'action' => true, // same as above
         *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
         *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
         * );
         * </code>
         *
         * @var array
         */
        private static $allowed_actions = array (
        );

        public function init() {
                parent::init();
                // You can include any CSS or JS required by your project here.
                // See: http://doc.silverstripe.org/framework/en/reference/requirements
        }

}
@christopherdarling
@kmayo-ss

Thanks Christopher
@ellecarrier would be good to close this issue as it seems to be a duplicate of
silverstripe/silverstripe-widgets#26

@simonwelsh simonwelsh added the 3.1 label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.