MuchDev Posted April 19, 2015 Share Posted April 19, 2015 Hey all, currently building a newsletter builder that can create newsletters from fields and existing items as well as repeater fields that have more content areas. As you can see from all this there are a lot of scenarios in which one field will be hidden while others are visible. With this in mind I am attempting to set all my fields so that they display conditionally based on a couple inputfieldSelect boxes. This is going well for nearly all fields up until the point in which I need to use a != selector. Here are the select boxes with options that I am using to hide/show body and headline input fields. newsletterContentType **1:=New **2:=Linked Content newsletterContentLayout **1:= Single Column **2:= Two Column **3:= Compact Article Block So the one scenario is this, I would like to have a text box hidden if newsletterContentType=2 and newsletterContentLayout=2 or 3. As we are curently unable to have OR operators as specified by the documentation I have attempted to write it like: newsletterContentType!=2, newsletterContentLayout!=1 So the way that I interpret this to mean is * always show this field unless these two boxes are set like this * The problem with this code though is that processwire seems to interpret that expression to mean , = or. Is there to write this in a language that this field will understand? Link to comment Share on other sites More sharing options...
bernhard Posted April 19, 2015 Share Posted April 19, 2015 since 2.5.24 OR-dependencies are possible: https://processwire.com/blog/posts/processwire-core-updates-2.5.24/#field-dependencies-upgrades 3 Link to comment Share on other sites More sharing options...
kongondo Posted April 19, 2015 Share Posted April 19, 2015 (edited) ...and in the documentation as well: http://processwire.com/api/selectors/#or-groups Edit: sorry, this is a different matter; ignore my post... Edited April 19, 2015 by kongondo 2 Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 19, 2015 Share Posted April 19, 2015 ...and in the documentation as well: http://processwire.com/api/selectors/#or-groups Sadly that's not right. OR groups are still not supported for inputfield dependencies. Also the docs are here, where by now it's still stating, that or-operators do not work: https://processwire.com/api/selectors/inputfield-dependencies/#limitations @MuchDev Keep in mind, that inputfield dependencies do not work inside of repeaters. You can hide the whole repeater field, but you can't use them inside of repeater "templates" and you can't show/hide anything based on values inside of repeater items. There were some efforts by Soma to make them work, but I'm not sure about the state and reliability of it. 2 Link to comment Share on other sites More sharing options...
kongondo Posted April 19, 2015 Share Posted April 19, 2015 Here I go again not reading things properly....I was obviously talking about something different....Thanks for the correction @LostKobrakai 2 Link to comment Share on other sites More sharing options...
MuchDev Posted April 21, 2015 Author Share Posted April 21, 2015 Thanks for the replies everyone, this really clears things up. Here I go again not reading things properly....I was obviously talking about something different....Thanks for the correction @LostKobrakai Hehe, so self reflective . Sadly that's not right. OR groups are still not supported for inputfield dependencies. Also the docs are here, where by now it's still stating, that or-operators do not work: https://processwire.com/api/selectors/inputfield-dependencies/#limitations @MuchDev Keep in mind, that inputfield dependencies do not work inside of repeaters. You can hide the whole repeater field, but you can't use them inside of repeater "templates" and you can't show/hide anything based on values inside of repeater items. There were some efforts by Soma to make them work, but I'm not sure about the state and reliability of it. Thanks for clarifying, I did read that it was possible and the document said otherwise, I guess I was just hoping that the documentation was just a tad out of date. Too bad that this doesn't work, it's going to make this line in the repeater a little more confusing to the editors at first, but I'm sure they will forgive me . Link to comment Share on other sites More sharing options...
renobird Posted April 21, 2015 Share Posted April 21, 2015 Keep in mind, that inputfield dependencies do not work inside of repeaters. That's not exactly true. Repeaters do support dependencies, but only for field=value. You have to set 'useDependencies' => false in your config.php — and that can have undesired consequences. I haven't tried this, but instead of setting that in the config file, it might be possible to set it on a per-template basis using a hook. 2 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