Robin S Posted July 2, 2020 Author Share Posted July 2, 2020 2 minutes ago, sz-ligatur said: I guess there is a typo in CustomInputfieldDependencies.module @Line 52 Thanks, fixed in v0.2.1. Link to comment Share on other sites More sharing options...
digitex Posted July 2, 2020 Share Posted July 2, 2020 @Robin S I just installed the latest version and upgraded from 1.9 to 2.1 (this morning). BRILLIANT!!!! Beautifully done. It works perfectly. Thanks again for a very handy module. 1 Link to comment Share on other sites More sharing options...
regesh Posted July 14, 2020 Share Posted July 14, 2020 Thanks for this module! It saved many hours for me. And one more thing i noticed. It has some bugs with toggle field value as dependency and when is used for field_tab But all other are works grate!)) Thanks again! Link to comment Share on other sites More sharing options...
Robin S Posted July 14, 2020 Author Share Posted July 14, 2020 2 hours ago, regesh said: It has some bugs with toggle field value as dependency and when is used for field_tab @regesh, that's a pretty vague statement. A proper bug report needs to include an exact description of the bugs and steps to reproduce them. Otherwise it's difficult to respond. As far as I can see the module works with FieldtypeToggle just fine. If you want to match a Toggle field in a selector you have to use the integer value - that isn't specific to this module, it's the way the PW core works. And by "field_tab" do you mean the core "Fieldset in Tab (Open)" aka FieldtypeFieldsetTabOpen? The module also works fine with this fieldtype so I don't understand the problem. If instead you are talking about the tab option of the non-core FieldsetGroup module that is part of ProFields then I've added support for that in v0.2.2. Link to comment Share on other sites More sharing options...
regesh Posted July 15, 2020 Share Posted July 15, 2020 Thanks' for reply. I'll check with "toggle" later. Link to comment Share on other sites More sharing options...
gornycreative Posted March 7, 2023 Share Posted March 7, 2023 Would I be able to use this to check if a repeater matrix item has any items assigned? I want to set up a drop down that only appears when a repeater is populated. Link to comment Share on other sites More sharing options...
Robin S Posted March 7, 2023 Author Share Posted March 7, 2023 6 hours ago, gornycreative said: Would I be able to use this to check if a repeater matrix item has any items assigned? I want to set up a drop down that only appears when a repeater is populated. Did you try something already and it didn't work? You should be able to use either the "Show only if page is matched by selector"... your_matrix_field.count>0 ...or the "Show only if custom PHP returns true" setting... $items = $page->getFormatted('your_matrix_field'); if($items && $items->count) return true; If you were wanting to do the opposite, i.e. show the field only when the matrix field is empty, then it should work to put "your_matrix_field.count=0" into the "Show only if page is matched by selector" setting but unfortunately there seems to be a core PW bug: https://github.com/processwire/processwire-issues/issues/1701 So until that's fixed you'd need to use the "Show only if custom PHP returns true" setting instead: $items = $page->getFormatted('your_matrix_field'); if($items && !$items->count) return true; Link to comment Share on other sites More sharing options...
gornycreative Posted March 8, 2023 Share Posted March 8, 2023 I tried using the simple matrix_field.count>0 rule, but it didn't work. I didn't realize I needed to include the inputfieldset name also. e.g. matrix_wrapper_fieldset.matrix_field.count>0 EDIT: Nope that didn't fix it. It just stopped showing anything. For some reason it is not recognizing the count of the matrix items. Is the data-show-if attribute in the HTML supposed to be escaped? e.g. data-show-if='meta_zone_1.count>0' data-required-if='meta_zone_1.count>0' Link to comment Share on other sites More sharing options...
Robin S Posted March 8, 2023 Author Share Posted March 8, 2023 4 hours ago, gornycreative said: I tried using the simple matrix_field.count>0 rule, but it didn't work. I didn't realize I needed to include the inputfieldset name also. e.g. matrix_wrapper_fieldset.matrix_field.count>0 I don't know what the field structure is in your template. It should work fine as described in my previous post. Inputfield names doesn't have much to do with it - you use field names just as you would in any selector. If the selector matches your page in $pages->find($selector) then it should work in the "Show only if page is matched by selector" setting. Seeing screenshots of your template fields and the settings you have chosen for CustomInputfieldDependencies would help. 5 hours ago, gornycreative said: Is the data-show-if attribute in the HTML supposed to be escaped? e.g. data-show-if='meta_zone_1.count>0' data-required-if='meta_zone_1.count>0' That isn't related to this module. It comes from the core show-if and required-if features, so if you are seeing that in your markup it means you are not using the features added by CustomInputfieldDependencies. See the screenshot below. Link to comment Share on other sites More sharing options...
gornycreative Posted March 8, 2023 Share Posted March 8, 2023 I'm sorry I should have been clearer. I haven't tried your module yet, I was just trying to use the core method (which wasn't working for me) and I was asking if your extended module would perform in a way that the default setup did not. I will give it a try. Link to comment Share on other sites More sharing options...
Christophe Posted July 28 Share Posted July 28 Hello Robin, Your module is so helpful/useful. I'm using "Show only if page is matched by custom find" and the parent (page) id. Thank you! 1 Link to comment Share on other sites More sharing options...
Robin S Posted July 28 Author Share Posted July 28 @Christophe, glad you find it useful. 5 hours ago, Christophe said: I'm using "Show only if page is matched by custom find" and the parent (page) id. Technically you don't need Custom Inputfield Dependencies if you want to show/hide a field according to the parent page ID. The PW core includes a "Parent" field in Page Edit on the "Settings" tab. This field is named "parent_id" so you can do something like this: 1 Link to comment Share on other sites More sharing options...
Christophe Posted July 29 Share Posted July 29 (edited) For me, parent_id= 1314 or parent.id=1314 in "Show this field only if" doesn't work. It hides the field. It works only as expected in "Show only if page is matched by custom find" or in "Show only if page is matched by selector" where I put this time parent.id=1314 that was given by the "Show only if page is matched by custom find" field when I was using it before. In Visibility, I'm using "Open when filled + Closed when blank". Edit: I didn't deactivate your module when trying it, but I don't think it could have had an impact on the result. Edited July 29 by Christophe Link to comment Share on other sites More sharing options...
Christophe Posted August 8 Share Posted August 8 (edited) So, I had parent.id=1314 in "Show only if page is matched by custom find", and the editor wants also the video field showing on a specific page not included by the first filter. I can't have it work. So, out of curiosity, I tried again in "Show this field only if". And parent.id=1314 || id=1250 works (parent.id=1314 | id=1250 also). And I don't know why but this time parent_id=1314 alone works (but not parent_id=1314 || id=1250 - with the double or single pipe operator - for the specific page). I don't know if all this is "normal". There is certainly an explanation. Edit: The field appeared for the page (with id 1250) but I had the impression that it wouldn't work and it didn't (the video disappeared after saving the page). Also, it blocked, at least for this specific page and the children of the "parent" page, the "View" link. In fact, I had to just put id=1250 to make it work. Now, I'm back with parent.id=1314 in "Show only if page is matched by custom find". The field is hidden but the video is still there. I might just create another template for this specific page, as the video appears at the bottom after a lot of content in this particular case and should preferably be at the top. Edited August 8 by Christophe Link to comment Share on other sites More sharing options...
Robin S Posted August 8 Author Share Posted August 8 @Christophe, I can't follow what you're doing so if you have a question specifically about Custom Inputfield Dependencies rather than the core show-if features then please rephrase it and include some screenshots. For now what I can say is: Custom Inputfield Dependencies uses the $pages->find() selector syntax as described in the PW docs. This is a different syntax than the core show-if selectors, so you can't just copy/paste selectors from one to the other. Syntax like "parent.id=1314 || id=1250" and "parent.id=1314 | id=1250" is not valid for $pages->find(). If you want to match one field/value combination OR a different field/value combination then you need to use OR-group syntax: https://processwire.com/docs/selectors/#or-groups And InputfieldSelector (the inputfield used by Custom Inputfield Dependencies for "Show only if page is matched by custom find") doesn't support OR-groups so you would have to use a selector string in "Show only if page is matched by selector". (parent.id=1314), (id=1250) 1 Link to comment Share on other sites More sharing options...
Christophe Posted August 12 Share Posted August 12 I think I had tried it in "Show only if page is matched by selector" but without the parentheses, based on what "Show only if page is matched by custom find" was displaying (but yes it was saying that 0 pages corresponded). With the brackets it works. Thank you! 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