processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Custom image fields: show-if prevents value save, required-if not working

Open Toutouwai opened this issue 1 year ago • 2 comments

Short description of the issue

There are issues when using show-if and required-if settings for custom image fields.

In the example below the text_2 field has a show-if condition text_1!=''. This prevents any value from being saved to the text_2 field.

showif

If I remove the show-if condition and add a required-if condition text_1!='' then this condition isn't enforced and no error message is shown when text_1 is populated and text_2 is left empty.

requiredif

Setup/Environment

  • ProcessWire version: 3.0.236

Toutouwai avatar Feb 28 '24 23:02 Toutouwai

As far as I know/remember, we have not specifically built support for field dependencies in custom image fields. This is the sort of thing that might take a lot of work to support support, or not. I'm not really certain without diving in. I'll keep this in the queue as a requested feature.

ryancramerdesign avatar Mar 28 '24 15:03 ryancramerdesign

@ryancramerdesign, perhaps useDependencies could be set to false for the custom fields InputfieldWrapper? Maybe adding the line below here

$inputfields->useDependencies = false;

Then showIf conditions would work via the JS side only. They wouldn't get the extra validation on the PHP side but at least the field value would save, so still an improvement.

It would need a different solution to get requiredIf working, but that could come later. I proposed a possible solution for requiredIf in repeater items here, and perhaps something similar would work for image/file custom fields?

Toutouwai avatar Jun 01 '24 03:06 Toutouwai