4

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?

suo
  • 599
  • 7
  • 25
  • Seems like a missing feature; there are definitely cases where you'd want different validation for the create/edit states, like the `unique` rule. I'd consider opening an issue on the Voyager github page (or browsing open issues for a similar one) – Tim Lewis Sep 07 '18 at 15:06
  • 1
    Hi Tim. already opened a ticket. awaiting a response. though have resolved to solve the issue on my own by overriding the edit method. will see what i come up with – suo Sep 07 '18 at 15:18

2 Answers2

9

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

suo
  • 599
  • 7
  • 25
0

You can just set the rule on the column to the following

{
    "rule": "nullable"
}