mel47 Posted May 28 Share Posted May 28 (edited) Hi, I want to show some custom fields from an image depending on the page id. However just a showIf = parent.id=1042 doesn't work. (1042 is the page, not the image) Is it possible by a different syntax? Thanks Mel Edited June 1 by mel47 SOLVED - update of module by RobinS Link to comment Share on other sites More sharing options...
AndZyk Posted May 28 Share Posted May 28 (edited) Hi @mel47, you mean show by using field dependencies? If the field is not inside a repeater field, than id=1042 would be enough. If the field is inside a repeater field I am not sure, but I think it would be possible with this module: https://processwire.com/modules/custom-inputfield-dependencies/ Regards, Andreas Edited May 28 by AndZyk Link to comment Share on other sites More sharing options...
mel47 Posted May 31 Author Share Posted May 31 Hello, That was my first guest, but it didn't work. However it finds the good page. But then, the field is not appearing. Image from page 1042 is without publication_date field : I'm not sure if I don't have the good syntax or if it's a limitation? Thanks. Link to comment Share on other sites More sharing options...
Robin S Posted June 1 Share Posted June 1 @mel47, currently the PW core does not support showIf or requiredIf in custom fields for files/images. See this issue: https://github.com/processwire/processwire-issues/issues/1889 And even if that issue is resolved, the way the core is handling showIf/requiredIf at the moment means that it will only evaluate the showIf/requiredIf based on values of other custom fields for the image/file item, not fields in the page that is open in Page Edit. But I've just updated the CustomInputfieldDependencies module so that it should handle your case. Please update the module to v0.3.0 and test it again. 5 1 Link to comment Share on other sites More sharing options...
mel47 Posted June 1 Author Share Posted June 1 Hi @Robin S, Yes it works perfectly! It's wonderful, thanks so much!!! 1 Link to comment Share on other sites More sharing options...
kixe Posted June 5 Share Posted June 5 I came across this problem and solved it with a hook. In my case, I use the image field in 2 different repeaters and needed a dependency on the template. Field names of custom image fields always contain the ID of the page or repeater page to which the image field is assigned. e.g. "image_caption_image_repeater18596_9cc494cc88e6dc55046f042aa5b3492d" whereas 18596 is the page / repeater page id wire()->addHookAfter('InputfieldWrapper::renderInputfield', function($e) { $inputfield = $e->arguments[0]; if (strpos($inputfield->name, 'image_caption_image_repeater') === 0) { $pid = (int) strstr(substr($inputfield->name, strlen('image_caption_image_repeater')), '_', true); $tn = wire('pages')->get($pid)->template->name; if ($tn == "repeater_cards") $e->return = ''; } }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now