Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

TreeDropDownField in Widgets - CMS error #2906

Closed
ellecarrier opened this Issue Feb 28, 2014 · 4 comments

Comments

Projects
None yet
5 participants

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

Contributor

kmayo-ss commented Mar 3, 2014

What version of CMS and framework are you using

Contributor

kmayo-ss commented Mar 3, 2014

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
        }

}
Contributor

christopherdarling commented Mar 3, 2014

pretty sure they're meaning TreeDropdownField usage on Widgets. There's a
ticket on the Widgets module for this (silverstripe/silverstripe-widgets#26), my comment at the end shows another module that can be used as a workaround for this,
it uses GridField to manage the Widgets instead of the WidgetAreaEditor

On 3 March 2014 21:14, kmayo-ss notifications@github.com wrote:

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?

'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. * * * 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 * ); * * * @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 } ``` } ## Reply to this email directly or view it on GitHubhttps://github.com/silverstripe/silverstripe-framework/issues/2906#issuecomment-36560468 .

Kind Regards,
Christopher Darling
www.christopherdarling.co.uk

Contributor

kmayo-ss commented Mar 3, 2014

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 Mar 15, 2014

@chillu chillu closed this May 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment