Silverstripe Version: 3.7.3
Question: How to add a Uploadfield within ModelAdmin GridField and work with file?
I’m trying to add a custom uplaod functionality to a model admin. I know that an GridField Import Button is build in with Silverstripe 4* but unfortunatly I have to do this with a 3.7.3 project…
Currently I built a GridFieldUpload class wich implements GridField_HTMLProvider, GridField_ActionProvider, GridField_URLHandler.
With the getHTMFragments Function I’m able to build a button:
public function getHTMLFragments($gridField)
{
$field = new GridField_FormAction(
$gridField,
'upload',
'Upload File',
"upload",
null
);
$field->addExtraClass('no-ajax action_upload');
$field->setForm($gridField->getForm());
return [
$this->targetFragmentButton => $field->Field()
];
}
But I can’t figure out how to add an uploadfield here instead of an actionButton. I want to upload an XLSX File and do something with exactly that file. So I want to trigger the upload and the following action with one button. Does someone know how this is possible?
I already tried to look into the code of SS4 “GridFieldImportButton.php” but I could not handle that within my code. I also tried to include the V 2.1.11 of Colymba/GridFieldBulkEditingTools but also failed with this implimentation (I got a uploadfield but it wasn’t possible to upload a file).