Popular Post ryan Posted August 21, 2013 Popular Post Share Posted August 21, 2013 Field dependencies are coming in ProcessWire 2.4, and I just wanted to give you guys a little preview of it. The development of this new feature is being sponsored by Avoine, the company where Antti works (he also specified how it should work). Field dependencies are basically just a way of saying that one field depends on another. It dictates which fields should be shown in a given context. In our case, it also gets into whether a field is required or not. This short video demonstrates how it works: (switch to the 720p and full screen version, as YouTube's default settings for this video make it impossible to see): // Edit @Adamkiss: Here's link for those on mobile: youtu.be/hqLs9YNYKMM The implementation here is done both client-side and server side. Javascript handles the showing/hiding of fields and the required vs. not required state changes. On the server side, it doesn't process any fields that aren't shown, and honors the required rules. A separate processing occurs both client side and server side, ensuring that the user can't make their own rules by manipulating the markup or post data. These field dependencies can be used with any Inputfield forms. That means you'll be able to use it not just in ProcessWire, but in FormBuilder, and via the API too. It's very simple to use from the API. All you have to do is specify a ProcessWire selector to either "showIf" or "requiredIf" to the Inputfield, and ProcessWire takes care of the rest: // show this field only if field 'subscribe' is checked $inputfield->showIf = "subscribe=1"; // show this field only if 'price > 0' and at least one category selected $inputfield->showIf = "price>0, categories.count>0"; // make this field required only if 'email' is populated $inputfield->required = true; $inputfield->requiredIf = "email!=''"; This feature will be in the 2.4 core (rather than as a separate module), so it will also be ready and available for things like module and field configuration screens. 55 Link to comment Share on other sites More sharing options...
apeisa Posted August 21, 2013 Share Posted August 21, 2013 This is epic. Thanks for building it Ryan. Couldn't be happier with how it turned to be! 14 Link to comment Share on other sites More sharing options...
Soma Posted August 21, 2013 Share Posted August 21, 2013 Awesome thanks avoine! 7 Link to comment Share on other sites More sharing options...
netcarver Posted August 21, 2013 Share Posted August 21, 2013 Like it. Like it. Like it! Thanks to Ryan and Antti. @Ryan - would be great to get an audio explanation on your demo videos if possible 3 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted August 21, 2013 Share Posted August 21, 2013 Thank you Apeisa & Ryan. More then awsome. 4 Link to comment Share on other sites More sharing options...
arjen Posted August 21, 2013 Share Posted August 21, 2013 Great SUPERB work! Can't believe how mature this already looks and feels! Thanks Ryan and Antti/Avoine. 4 Link to comment Share on other sites More sharing options...
netcarver Posted August 21, 2013 Share Posted August 21, 2013 Hehe Antti - I seem to recognise the showIf() and requiredIf() calls from somewhere 1 Link to comment Share on other sites More sharing options...
apeisa Posted August 21, 2013 Share Posted August 21, 2013 Hehe Antti - I seem to recognise the showIf() and requiredIf() calls from somewhere Oh yes. I remember those irc discussions very well. I actually ended building my own form class, which was conceptually kind of mixture from your work and pw inputfields. Field dependencies are a very powerful concept and it gives great pleasure to define once and see it just work in backend and frontend. I am actually pretty hooked on that video. Have watched it three times already 2 Link to comment Share on other sites More sharing options...
arjen Posted August 21, 2013 Share Posted August 21, 2013 Have watched it three times already Just three times? 3 Link to comment Share on other sites More sharing options...
apeisa Posted August 21, 2013 Share Posted August 21, 2013 Just out of interest: is there similar features in other cms you guys have used? Link to comment Share on other sites More sharing options...
renobird Posted August 21, 2013 Share Posted August 21, 2013 Thanks to Avoine, Ryan, Antti. This is exciting/powerful/wonderful! 3 Link to comment Share on other sites More sharing options...
Wanze Posted August 21, 2013 Share Posted August 21, 2013 Holy..... whatever. I'm smiling like a king right now. Thanks Antii and ryan! 3 Link to comment Share on other sites More sharing options...
renobird Posted August 21, 2013 Share Posted August 21, 2013 Just out of interest: is there similar features in other cms you guys have used? There is something that can give you a similar functionality in Textpattern (bot_wtc), but it doesn't translate to the frontend at all. 1 Link to comment Share on other sites More sharing options...
kongondo Posted August 21, 2013 Share Posted August 21, 2013 OK, what programme did you use to make that spoof video?! After effects or something? My goodness! Avoine/Antti, thank you very much!!! As for you Mr Cramer, I don't know what to tell you. Seriously, mate, I can't pick an adjective apt enough. Let's just say that you Sir are one of the best things that has happened to the open source community. Hats off! cheers /k 8 Link to comment Share on other sites More sharing options...
arjen Posted August 21, 2013 Share Posted August 21, 2013 I used Gravity Forms a couple of times. While it is build for front-end forms I really like the way the depencies are build there with multiple conditions aka conditional logic. 4 Link to comment Share on other sites More sharing options...
diogo Posted August 21, 2013 Share Posted August 21, 2013 Amazing work! thanks guys 1 Link to comment Share on other sites More sharing options...
Soma Posted August 21, 2013 Share Posted August 21, 2013 I just watched the video at home (damn mobile won't let me). Amazing feature to have! Watching this I think the "required" need to be more visible or red (asteriks). It can be missed too easily. And the show animation need to be much quicker! (lol) Not can we have also a hideIf() and a makeCoffeeIf()... I already see the forum full of posts "It doesn't show when..." 4 Link to comment Share on other sites More sharing options...
apeisa Posted August 21, 2013 Share Posted August 21, 2013 I used Gravity Forms a couple of times. While it is build for front-end forms I really like the way the depencies are build there with multiple conditions aka conditional logic. That looks great. I think we have similar powers with selectors, of course requires some knowhow of selectors and field names. 1 Link to comment Share on other sites More sharing options...
MadeMyDay Posted August 21, 2013 Share Posted August 21, 2013 Almost crying right now. Or having multiple orgasms. Or both. So awesome. 8 Link to comment Share on other sites More sharing options...
owzim Posted August 21, 2013 Share Posted August 21, 2013 It's weird how stuff Ryan puts out there always seems to be pretty much rock solid from the beginning. Awesome stuff.Thanks Ryan, Antti and Avoine!Edit: how are the variable widths controlled? There have to be many different situations for those fields on one row. When d they get a new dedicated row if there too many popping up in one row (like the checkbox example with "Pool" and "Children welcome")? Link to comment Share on other sites More sharing options...
doolak Posted August 21, 2013 Share Posted August 21, 2013 Wow! 1 Link to comment Share on other sites More sharing options...
apeisa Posted August 21, 2013 Share Posted August 21, 2013 Edit: how are the variable widths controlled? There have to be many different situations for those fields on one row. When d they get a new dedicated row if there too many popping up in one row (like the checkbox example with "Pool" and "Children welcome")? I asked the same question from Ryan. It is pretty clever stuff actually: So I set it up to do this: after any dependency action occurs, it maximizes the space available to the row of fields. It does this by modifying the last field in the row to consume the available space. There's actually a lot more to it than that (it took an entire day to get it right) but that's the gist of it. It also does this when the page is initially rendered. There is also a hint why Ryan deliveres rock solid from the beginning 8 Link to comment Share on other sites More sharing options...
dotnetic Posted August 21, 2013 Share Posted August 21, 2013 Did i mention that i love you? Thanks for this great feature 1 Link to comment Share on other sites More sharing options...
renobird Posted August 21, 2013 Share Posted August 21, 2013 it took an entire day to get it right yeah, so that's a week to everyone/anyone else. 7 Link to comment Share on other sites More sharing options...
netcarver Posted August 21, 2013 Share Posted August 21, 2013 About 2 months for me. 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