lenoir Posted May 23, 2014 Share Posted May 23, 2014 Probably basic, but can anyone tell me how to show a particular field if the 2nd element of a radio is selected? Thank you. Link to comment Share on other sites More sharing options...
PCkuijper Posted July 21, 2014 Share Posted July 21, 2014 Hey Ryan, I've loved the field dependencies the moment we finally upgraded to processwire 2.4. The only thing i'm truely missing is a way to select with an OR value. I'm currently using field dep. to make "widgets" for lack of a better name and not every "widget" has a body, but multiple do use the body. Currently it seems I'm stuck using multiple body tags unless I'm mistaken. Bassicly I'm looking for a way to use the body field if widget_type == "type1" OR "type2" Is this a possibility or will this be a feature implemented in the future? Keep up the awesome work you do. Processwire has quickly become my favourite system to work with. Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 21, 2014 Share Posted July 21, 2014 (edited) OR Selectors are in the durrent dev version: https://processwire.com/talk/topic/3768-processwire-dev-branch/page-10#entry64049. I don't know if they work for field dependencies. Edited July 21, 2014 by LostKobrakai Link to comment Share on other sites More sharing options...
renobird Posted July 21, 2014 Share Posted July 21, 2014 This is a bit old, but I'm stubbing my toe on it. Actually, you can do this on the dev branch. Lets assume that cities are children of countries and that is reflected in your page structure (i.e. /countries/france/paris/). Create your 2 page fields (country and city), and configure 'country' as a single page field with "parent" set to "/countries/". Next, for the "city" field configuration, use the "Custom selector to find selectable pages", present on the "input" tab. In that field, enter "parent=page.country". Save and try it out. This works with select, selectMultiple and asmSelect fields (and possibly others), though not yet with checkboxes, radios or PageListSelect. I have this working, but when nothing has been selected for "country" the "city" select shows all the root pages starting with home. Is the only way around that to set the "city" visibility to country!="" ? Perhaps I'm just being dense today, but I can't find any other way around it. Link to comment Share on other sites More sharing options...
bwakad Posted August 25, 2014 Share Posted August 25, 2014 This is a bit old, but I'm stubbing my toe on it. I have this working, but when nothing has been selected for "country" the "city" select shows all the root pages starting with home. Is the only way around that to set the "city" visibility to country!="" ? Perhaps I'm just being dense today, but I can't find any other way around it. Have the same issue using the latest dev branch. I think something changed in the core... If I specify for my province select field also a template parent=page.country, template=mytemplate I end up with the name of the template as a value when nothing is selected in the first select. So no good! - edit - the field which depend on another field, in my case "province" depends on "country": in province visibility, and show this field only if... I use "country>0" This hides the province field, until I select a country. Then it just shows the corresponding values. It's a pitty this cannot be done on the front-end though... Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 26, 2014 Share Posted August 26, 2014 I was just wondering if it is possible to use roles as dependency? I've read Ryans post https://processwire.com/talk/topic/4323-field-dependencies/page-3#entry42957 and thought it might be possible. Has someone an answer to this question? I would like to make a membership number required but only for members and not for admins. 1 Link to comment Share on other sites More sharing options...
patrickvibes Posted September 12, 2014 Share Posted September 12, 2014 Actually, you can do this on the dev branch. Lets assume that cities are children of countries and that is reflected in your page structure (i.e. /countries/france/paris/). Create your 2 page fields (country and city), and configure 'country' as a single page field with "parent" set to "/countries/". Next, for the "city" field configuration, use the "Custom selector to find selectable pages", present on the "input" tab. In that field, enter "parent=page.country". Save and try it out. This works with select, selectMultiple and asmSelect fields (and possibly others), though not yet with checkboxes, radios or PageListSelect. Just discovered my need for this on a mission to try something and I must say...awesome. Couldn't get it working at first my confusion lay in the fact I was calling: parent=page.province thinking it referred to the page but it's the field I needed to target i.e. parent=page.country_province - where "country_province" is the name of the select field I am using. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 19, 2014 Share Posted September 19, 2014 I was just wondering if it is possible to use roles as dependency? I've read Ryans post https://processwire.com/talk/topic/4323-field-dependencies/page-3#entry42957 and thought it might be possible. Has someone an answer to this question? I would like to make a membership number required but only for members and not for admins. I just figured it out. I read in another thread (can't remember which), that roles do have subfields like roles.name. Using these did not work, but I found that ProcessLister used the id's in it's selectors instead of the names. So just look for the id of your role and use "roles=ID" in the dependency field. Link to comment Share on other sites More sharing options...
gebeer Posted October 22, 2014 Share Posted October 22, 2014 It seems like OR in dependencies is not working for radio buttons. I want to show a field only some specific options of the radio input "ad_frequency" are checked. I tried this in field dependencies settings: ad_frequency=1082, ad_frequency=1083, ad_frequency=1084 If I set it to a single radio option like ad_frequency=1082 everything is working as expected. In the docs it says that this will be implemented. Does anyone know, when? 1 Link to comment Share on other sites More sharing options...
sforsman Posted October 22, 2014 Share Posted October 22, 2014 @gebeer: No idea Link to comment Share on other sites More sharing options...
gebeer Posted October 22, 2014 Share Posted October 22, 2014 @sforsman Thanks, but not working. I get a JS error Uncaught Error: Syntax error, unrecognized expression: #Inputfield_ad_frequency_1082|1083|1084 Attribute data-show-if="ad_frequency=1082|1083|1084" in the field wrapper. I'm on 2.5 stable and on a frontend form where other dependencies are working fine. Link to comment Share on other sites More sharing options...
gebeer Posted October 28, 2014 Share Posted October 28, 2014 Does anyone know when OR condition s will be available?I' be willing to donate towards developmentin near future. Link to comment Share on other sites More sharing options...
dragan Posted December 5, 2014 Share Posted December 5, 2014 This may not be the right place to post, but I'll try anyway... I'm currently preparing a little presentation to introduce PW to our company. Most stuff we do development-wise, is strictly frontend. But every now and then, we do backend stuff too, which mostly (always?) ends with choosing Wordpress. "Because it's so famous", "because it's the only CMS our other in-house developers also know", "because there are so many plug-and-play themes/plugins"... There are a few medium-sized projects coming up where we won't only cover the frontend, so I thought it was time to introduce folks here that - yes indeed - there are worthwhile alternatives out there. I've got maybe 80% of the material together that I'd like to present, but I was wondering if there is a PW-profile of the hotel website which is shown in Ryan's video @ http://processwire.com/api/selectors/inputfield-dependencies/ (or any other similar profile / demo site which uses field dependencies). If possible, I'd like to walk through a demo-install with people, and maybe even let them play around themselves. Too many folks here actually have no clue when it comes to backend dev work. I'd like to show them how much can be achieved, with "out of the box" PW tools, even for heavily customized stuff. And certainly, Field Dependencies is such a corner-stone. Link to comment Share on other sites More sharing options...
Alexander Posted December 22, 2014 Share Posted December 22, 2014 @LostKobrakai So just look for the id of your role and use "roles=ID" in the dependency field. You using in "show this field only if" with something like "roles=1011" and this is working for you? Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 25, 2014 Share Posted December 25, 2014 I used it for "required if" and that's working. I don't know if it's the same for "show if". Link to comment Share on other sites More sharing options...
awebcreature Posted December 25, 2014 Share Posted December 25, 2014 Is it also possible within a repeater field? I tried it with this selector: parent=page.name-repeaterfield.country but it is probably missing the individual repeater field (or maybe is it not possible at all this way). I have the same problem. It is possible within a repeater field? When they are outside from repeater , no problem. Any help? Link to comment Share on other sites More sharing options...
awebcreature Posted January 10, 2015 Share Posted January 10, 2015 No one seem to solve that problem. It is bug or is there a specific sollution? Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 10, 2015 Share Posted January 10, 2015 Each repeateritem is actually a hidden but real page, so they're assigned dynamic names. These include the id of the current repeater item, so I think the field dependencies don't work in repeaters, because the name matching just doesn't work. checkbox_1029 just isn't checkbox. Also the same field can be used normaly on the same page as the repeater field resides, so there could be a normal checkbox and some checkbox_1029, checkbox_1034. I don't know for sure, but I think, that's why Ryan left it out by now. Link to comment Share on other sites More sharing options...
awebcreature Posted January 13, 2015 Share Posted January 13, 2015 I tried with their dynamic name and all known ways (for me of course) without success. Ryan, please, can you help in that situation, workaround? Thanks! Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 13, 2015 Share Posted January 13, 2015 @awebcreature If you don't trust my explanation, here is a statement from Ryan that this is currently not intended to work. https://github.com/ryancramerdesign/ProcessWire/issues/803#issuecomment-64982758 Only option would be to hook the dependency management and add a own javascript file which handles the repeaters. Link to comment Share on other sites More sharing options...
awebcreature Posted January 13, 2015 Share Posted January 13, 2015 Thank you, LostKobrakai, for your explanation and that link to Ryan's post. Now I will try with PageTable field to solve that problem. All the best! Link to comment Share on other sites More sharing options...
Soma Posted January 13, 2015 Share Posted January 13, 2015 Some time ago I added support to core for repeaters, but it's very vage and uncomplete and only works with = operator. So it's already there for some time. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/InputfieldWrapper.php#L316 Thing was that it wasn't saving those fields anymore because of something else related, I can't really remember now. To enable fields with sowIf getting saved see in wire/config.php how to make it work. /** * Settings specific to InputfieldWrapper class * * Setting useDependencies to false may enable to use depencencies in some places where * they aren't currently supported, like files/images and repeaters. Note that setting it * to false only disables it server-side. The javascript dependencies work either way. * * Uncomment and paste into /site/config.php if you want to use this * * $config->InputfieldWrapper = array( * 'useDependencies' => true, * 'requiredLabel' => 'Missing required value', * ); * */ 1 Link to comment Share on other sites More sharing options...
renobird Posted January 14, 2015 Share Posted January 14, 2015 =operator dependencies still work fine in repeaters. At least as of 2.5.3 — haven't checked the dev branch. Link to comment Share on other sites More sharing options...
awebcreature Posted January 17, 2015 Share Posted January 17, 2015 WOW! Pagetable field is awesome! Thank you! Link to comment Share on other sites More sharing options...
Reid Bramblett Posted September 14, 2015 Share Posted September 14, 2015 Actually, you can do this on the dev branch. Lets assume that cities are children of countries and that is reflected in your page structure (i.e. /countries/france/paris/). Create your 2 page fields (country and city), and configure 'country' as a single page field with "parent" set to "/countries/". Next, for the "city" field configuration, use the "Custom selector to find selectable pages", present on the "input" tab. In that field, enter "parent=page.country". Save and try it out. This works with select, selectMultiple and asmSelect fields (and possibly others), though not yet with checkboxes, radios or PageListSelect. Can't puzzle this one out. I structure as you said (using categories/category/subcat, actually, but I'll stick to the geographic example to keep things simple), and it _looks_ as if it is working brilliantly. The proper set of cities pops up when I select a country. However, it won't save. After I click "save," the city select dropdown resets to nothing (in fact, it isn't even populated by any choices until I go back to the country dropdown and select something else), and the city info is not being saved to the database at all. I have painstakingly fiddled with each setting in the associated fields and templates and cannot get it working. Once idea: Could this possibly be because the template on which I am placing these dependent dropdowns belongs to pages that reside on a different branch of the page tree (not nested underneath, in this example, city)? Seems unlikely, but wanted to check before I pulled out still more hair over this. 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