ethanbeyer Posted March 29, 2017 Share Posted March 29, 2017 I'm kind of at a loss with this: I wrote a function inside one of my modules that saves files to a Page through the API. The Field is a FieldtypeFile. $page = $this->storagePage; $files = $page->pdfStorage_files; $files->add($path); return $page->save($files); I can see that the file has been saved to the Page's directory, and if I dump $page->filesManager->getFiles(); , the file I add is present in the array. But in the field_pdfstorage_files table in the database - no entry. Which also means that the file is not visible as a part of the pdfStorage_files field in the Admin Backend. Is there a way to ensure that adding the file to the field saves it everywhere? Link to comment Share on other sites More sharing options...
Robin S Posted March 30, 2017 Share Posted March 30, 2017 The $field argument supplied to $page->save() must be a field name or field object. But in your example $files is neither of these (it will be a Pagefiles object). 2 Link to comment Share on other sites More sharing options...
adrian Posted March 30, 2017 Share Posted March 30, 2017 Does this work? $p = $this->storagePage; $p->of(false); $p->pdfStorage_files->add($path); $p->save('pdfStorage_files'); return $p->pdfStorage_files; Not sure if your problem is the missing $p->of(false) or trying to save the $files pagefile object instead of the "pdfStorage_files" field name. PS - what @Robin S said 2 Link to comment Share on other sites More sharing options...
ethanbeyer Posted March 30, 2017 Author Share Posted March 30, 2017 Thank you both! It looks like it was $p->of(false); . I have next to no idea how the Output Formatting works. To the docs!! All my best!!! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now