View more context

 

manueltomasir

Hey friends..i'm trying to add an upload field that will allow my client to upload a csv into the CMS, and then i'm trying to run an onAfterWrite to load the csv into the system using the csvbulkloader...I have that all working...but I can't seem to be able to grab the URL of the file that is uploaded from within the onAfterWrite function....can someone help?

manueltomasir
    `$uploadField = UploadField::create('LocationCSV','Upload CSV of Locations');`
    `$uploadField->setFolderName('imports');`
    `$fields->addFieldToTab('Root.Locations',$uploadField);`

`}`

`public function onAfterWrite(){`

    `parent::onAfterWrite();`

    `echo("<pre>");`
    `print_r($this->LocationCSV);`
    `echo("</pre>");`
    `exit();`
manueltomasir

Undefined property: SiteConfig_Extension::$LocationCSV

phyzical

so you have a File Relation called LocationCSV on siteconfig ?

manueltomasir

alright so update...i was able to figure it out, I just had to access the ID of the file via $this->owner->LocationCSVID

manueltomasir

and then run a get on the object for the file itself

manueltomasir

now the issue i've run into is with the bulkloader itself

manueltomasir

I have the file uploaded into the assets directory, and although the loader works fine if the csv is in the root of the site, for some reason when it is in the assets directory, the cms instance stalls up on save

customPhpDev

How can we get data from DataList Object in template?