Search code examples
laravel-5.6voyager

Image field in edit mode still asking for image as a 'required' field


In the voyager backend, i set an image field as required in the BREAD section:

enter image description here

This works well in 'add' mode. image field will be validated if empty

Issue occurs in 'edit' mode. The image appears but on clicking on 'save', a prompt is thrown indicating the image field is empty(therefore requiring the image to be uploaded again):

enter image description here

therefore getting an 'Image field is required' prompt on edit. this appears to be a bug. Anyone experienced this issue and how did you fix it?


Solution

  • Found a solution from the ticket i had raised on Voyager's github's page:

    i.e. using required_if instead of required

    { "validation": { "rule": "required_if:id,null", "messages": { "required": "your message" } } }

    here's the ticket: Voyager image edit issue