Often an attribute will only be needed (and perhaps required) when another attribute takes on a particular value. For instance, perhaps an attribute may be Drupal user with a select box with the values Yes or No. If the user selects Yes, then another attribute, Drupal username, should be displayed and required.
This module defines another tab similar to the Attributes tab that lists in a table the attribute, a select box to choose another attribute on which it depends, the values of the parent attribute (using AHAH) which trigger the dependent attribute to be displayed and whether the attribute should be required when displayed. Often it is desirable to require the attribute but, since it is not displayed under some circumstances, it cannot be required in the same way as for most attributes. The dependencies are stored in a table and jQuery (Javascript) code is used to retrieve the data and display or not display the attributes.
Drupal 7 allows defining dependencies between form elements programatically so it has been recognized that this is an important capability. But Drupal 7 does not provide a user interface to specify the dependencies so a non-programmer can implement them. Drupal Commerce is not using attributes so the module would need to be quite different but may still prove useful for Drupal 7.
This module is currently being used on a Drupal website. It is written in such a way that it could be used on other websites.
Comments
Comment #1
trobey commentedComment #2
avpadernoHello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review the code, pointing out what it needs to be changed.
Comment #3
trobey commentedComment #4
wicketywick commentedSeems like an interesting module.
Just tried it on a test site of mine, doesn't seem to work. (the backend seems alright, but nothing happens on the frontend).
Can you post a screen of a configured node/20/edit/dependencies page? Maybe I configured something incorrectly.
I am no developer, just a simple drupal user.
Thanks.
Comment #5
trobey commentedThere is a screen shot in the post immediately preceding yours. Have you cleared the cache?
Comment #6
trobey commentedThis is an updated module that should fix the problem. There was one thing that was specific to the website that the module was developed for that needed to be made more general.
Comment #7
trobey commentedThere is a demo website for this module.
http://li57-250.members.linode.com/node/1
The student ID attribute only appears if the Continuing Education Credit attribute has the Yes option selected.
Comment #8
avpadernot().Code that doesn't use
db_query()-placeholders is considered not secure.Strings used in the user interface should be translated.
It should be drop down
Comment #9
avpadernoI am adding the tag we are using for Ubercart related modules.
Comment #10
avpadernoComment #11
trobey commentedI guess I gave up too early on getting a response to this request.
I have updated the code to address the comments. Note that item 4 is not correct. See https://drupal.org/node/473460:
"Note that if you are using strlen() just to check whether the length of a string is non-zero, it is not necessary to use the Drupal replacement."
strnlen() presumably executes quicker and so is to be preferred in this case.
The original code had been run through the coder module at the default setting. I ran it through at the most strict setting. I also have gone through the coding standards (again) and tried to catch as many problems as I could.
I also have gone through the code once again and found one function that needed to be renamed.
Comment #12
trobey commentedComment #13
jthorson commentedTrobey,
As Drupal has since moved over from CVS to Git, I'd suggest migrating this to a Git Full Project Access application as per http://drupal.org/node/1075406.
Comment #14
jthorson commentedComment #15
trobey commented@jthorson thanks for the information. It was very helpful. I have migrated this project to the Git sandbox at http://drupal.org/sandbox/trobey/1162770. I also have added a new demonstration website at http://dropdown.gaiaes.com/node/3
Comment #16
sreynen commentedUpdating title and tagging.
Comment #17
rfayYou can remove the $Id$ as we don't use those since the git migration.
Probably want to remove the '
' from within the t() in your long text; normally you only want the translatable stuff to be in there, not markup.
A @file header on each file would be nice. A function header for every function would also be nice.
Have you tested if this works with js off? Is that a goal?
It looks to me like this should go through OK.
Comment #18
trobey commentedI removed the $Id, html tags from t(), and added code documentation.
Showing or hiding the attributes uses Javascript so if Javascript is turned off then this functionality is lost. But it is designed to degrade gracefully by just showing all the attributes. For the administrative interface, there is a Change button that appears if Javascript is turned off which still allows the attribute dependencies to be specified. The Change button may not be obvious so some usability is lost but it should still work.
Comment #19
rfayWorks for me. Unless there are objections someone will come by and promote you to have full project permissions within the next several days. Thanks for your contribution and your future contributions! And thanks for your patience. Sorry this was so awful.
Comment #20
sreynen commentedHi trobey,
Thanks for your contribution and welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. As someone who has recently completed this process, your input would be especially useful in the code review group as we work to improve this process.
Comment #23
avpaderno