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.

Customising the CMS /

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

Add UploadField to ModelAdmin failed


Go to End


1330 Views

Avatar
allen

Community Member, 4 Posts

6 May 2016 at 11:51am

Edited: 06/05/2016 1:30pm

Hi, I am trying to add an UploadField to ModelAdmin, after the GridFieldList. But I always get an error " Call to a member function FormAction() on a non-object in ..../framework/forms/FormField.php on line 161". I can add TextField,DropdownField without any problems, but no luck with UploadField.
Did I miss something?

class MyExtension extends Extension{

    public static $has_one = array(
        'ImportCSV' => 'File'
    );

    public function updateEditForm($form){
        $fields = $form->Fields();

        $fields->push(
             new TextField('Title', 'Title')
        );//This one works

        $fields->push(
            new UploadField('ImportCSV', 'Import CSV')
        );//This one not working

    }
}

Thanks