I'm using Rules Forms to try and hide a field of the Organic Groups module from certain users when the "form is being built" event occurs. As luck would have it, the field I'm trying to hide is the only one on my form that doesn't show an Element ID to Rules Forms.
I found this recent patch http://drupal.org/node/758000#comment-2860086 and discovered that the Element ID does indeed exist after the form is built, but for some reason Rules Forms is unable to access it during the "form is being built" event. I would like to try and resolve this by either delving into the code of Rules Forms or Organic Groups in hopes of improving integration between Rules Forms and other modules.
Can someone explain why Rules Forms might not be able to access the Element ID on the "form is being built" event? Specifically I would like to know where in a module's code these Element IDs are generated in the first place. Is there a certain function that is called that would define the Element ID?
Comments
Comment #1
klausiRules Forms uses an after build handler to add those IDs. Most probably another module comes after Rules Forms and adds an element. Rules Forms should be the last called module so that it can add all element IDs. Have look at the system table and the module weights, Rules Forms should have the highest weight.
Comment #2
nodecode commentedThank you kalusi! That was the precise solution.
The module that I was working with was og_access which had a weight of 1. Rules Forms had a weight of 0 where as Rules had a weight of 20. I set Rules Forms to have a weight of 19 just to be safe in case it had to have a lesser weight than the core Rules module. Everything worked after that. I then reverted my version of Rules back to 6.x-1.2 and the previously missing Element ID was still created by Rules Forms without the aforementioned patch.
You said "Rules Forms should have the highest weight" so shouldn't it be at least greater than zero by default? I'm wondering if this is an easy-to-fix bug or is this by design?
Thank you again. I can't tell you how much I love this module.
Comment #3
klausiIf you update to 1.x-dev, there should be an upgrade routine that sets the module weight to 20. See also #557892: The presence or absence of text in a form element is inaccessible for Rules true/false testing purposes
Comment #4
nodecode commentedGlad to see this is fixed already. Looking forward to the next release :)
Comment #5
klausiMarking as duplicate of #557892: The presence or absence of text in a form element is inaccessible for Rules true/false testing purposes