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>
If you're writing an Extension (Specifically a DataExtension) then you'd use updateCMSFields($fields) which is passed an instance of FieldList by reference.
But to add the UploadField as I think you want, either add it to a DataExtension that extends (decorates) File in a call to updateCMSFields() or change extends Extension to extends DataExtension in your example above, and run dev/build flush=all