0

I am trying to add an UploadField to ModelAdmin by creating an extension, 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?

<code>
    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
        }
    }
</code>
4

1 回答 1

0

如果您正在编写Extension(特别是 a DataExtension),那么您将使用通过引用updateCMSFields($fields)传递的实例FieldList

但是要添加UploadField我认为你想要的,要么将它添加到在调用DataExtension中扩展(装饰)的 a 中,要么在上面的示例中更改为,然后运行FileupdateCMSFields()extends Extensionextends DataExtensiondev/build flush=all

于 2016-05-06T02:05:09.163 回答