When I test the upload feature, it seems like an upload field is not optional. For example,
import { CollectionConfig } from "payload/types";
const Test:CollectionConfig = {
slug: 'tests',
fields: [
{
name: 'metaCoverImage',
label: 'Cover Image',
type: 'upload',
relationTo: 'media',
required: true,
},
{
name: 'metaCustomOgImage',
label: 'Custom OG Image (front-end will fallback to cover image if not presented)',
type: 'upload',
relationTo: 'media',
},
]
}
export default Test;
The second upload field should be optional, however, it raises an exception when no upload is presented. Is this a design decision or a bug? If it is a design decision, then is there a way to have an optional upload?
Hey @hunghvu, it looks like a regression from the changes we made to futher validate upload and relationships. I'll get a fix out soon!
OK, this is fixed now, please upgrade to v1.0.30.
Thanks for asking or I wouldn't have caught it!
Can confirm that it was fixed. I always love this lightning-fast response from the team. Keep up the great work!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.