Hello everyone,
I’m facing a strange behaviour. For some context, i’m creating factories for my project in order to seed my content folder to reach different application states.
For one of my pages, i have a dedicated files
field with a custom template
File: fields/document.yml
type: files
multiple: false
query: page.files.template('document')
layout: cardlets
label: Document chargé
uploads:
template: document
And in my page blueprint, i have this field linked as below:
fields:
document: fields/document
So, in my factory, i create a file and then attach it to my page:
$file = File::create([
'template' => 'document',
'source' => $tmpFile,
'parent' => $page,
'filename' => basename($tmpFile),
'mime' => $type === 'image' ? 'image/jpeg' : 'application/pdf',
]);
$page = $page->update([
'document' => $file->filename(),
]);
All of this works well, the page and file gets created and i can access the file trough the document
field. But as soon as i run :
$page = $page->changeStatus('listed');
Now, the only thing that has changed in my content folder is the 1_
prefix on my page, but i cannot get my file trough the document field anymore (it is now set to ""
). I’ve tried to fetch the page once again but it changes nothing.
And if i run the changeStatus
method before creating the file, then it works all the way trough. I need to understand that behaviour as i fear that i’m doing something wrong that will backslash later.
Thanks a lot!
Sean.