I've activated a Views Exposed Filter form using the Rules Forms module and I'm now receiving the following error messages:
Notice: Undefined index: label in rules_forms_rules_event_info() (line 28 of C:\Users\Sites\f\sites\all\modules\contrib\rules_forms\rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 32 of C:\Users\Sites\f\sites\all\modules\contrib\rules_forms\rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 36 of C:\Users\Sites\f\sites\all\modules\contrib\rules_forms\rules_forms.rules.inc).
I've been able to go ahead and define a rule using 'form submit' as an Event, which then invokes an action to "Trim a Flag", which is an available Action available using the Flag module. In my implementation, anonymous users can set flags (which requires Session API)
Everything seems to be working as expected. When I hit 'submit' on the Exposed Filter Form, the number of flags are reset to 0 for the appropriate nodes. But the Notice still appears.
Let me know if you need additional information.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | rules-forms-label-error-1447328-7.patch | 1.52 KB | jordojuice |
Comments
Comment #1
jordojuice commentedHmm... since it's an error regarding the saving of forms within Rules Forms, I may be able to track it down without reproducing your environment. That particular variable should just store the label that the user assigns to the form when activating events for that form. It's curious that things are happening in that order. Maybe the Rules cache is getting reset which is why those variables are being checked.
Did this error occur right after you activated events for the exposed form? It should have happened right after saving the new form events because that's when the Rules cache is first rebuilt. I've never tried using form rules on a Views exposed filter form but I'm about to. Are you able to activate events for other forms without seeing this message?
What do you think the minimum requirements are for reproducing this? Might it occur with all Views exposed filter forms?
Comment #2
billp44ruby commentedIt happens right after activating the exposed filter form. I also went back and activated the search_block_form and received the same error message. So perhaps it is something unique to my configuration.
I'd also note that the once the form was activated, I took quite a performance hit for my application... almost to the point of making it unusable.
What additional information do you need to be able to reproduce it. I'm on Drupal 7.4.
Comment #3
jordojuice commentedThis has to be an issue with Rules Forms and views exposed forms. I'm sure that will be the case. It may be tough to track down what causes the disconnect when activating the form. I have a couple other things to work on at the moment but I'm sure I'll get to this soon.
Comment #4
Glenmoore commentedSame problem but no exposed filters at all here. My Rules act only on standard node creation forms and all Rules seem to function as expected but Error messages just keep returning.
Not using Flag Module but I am using Prepopulate Module to drop some values into the form.
"Notice: Undefined index: label in rules_forms_rules_event_info() (line 28 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 32 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 36 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 28 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 32 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc).
Notice: Undefined index: label in rules_forms_rules_event_info() (line 36 of /home1/letshagl/public_html/sites/all/modules/rules_forms/rules_forms.rules.inc)."
Using D7.10
Comment #5
jordojuice commentedOkay thanks for the report. It seems like this error message is independent of modules but may apply to some fairly unique circumstances. I should be able to reproduce on some form and hopefully track it down.
Comment #6
jordojuice commentedUgh... still unable to reproduce this. Of course, we could write an easy fix by checking for the label index before providing the form event info. What these particular lines of code are are the lines that tell Rules to add events like Node edit form is being built, Node edit form being the label index that is set by the user when activating events for the form. I just can't see any obvious reason in the code that would cause the label to fail at saving on certain forms. But maybe I'm looking for the wrong thing.
Is there any particular action either of you remember taking before the errors started to appear? Maybe resetting the form elements in Rules Forms administration? Or did they start appearing right after activating the forms? Or do they only appear after submitting the forms? Anything like that?
Comment #7
jordojuice commentedYou may be able to ignore my questions from my last comment. I think I may have found the issue, but this patch needs some testing. I think the module was improperly evaluating a form's elements even if it couldn't locate the form's ID. Meaning, it added information about the form to the internal Rules Forms settings under an improper ID. This means that the user never input a label for this form that doesn't actually exist, which is why the label error occurs. The module simply stored the settings as a separate form essentially but without a label or form ID. That would certainly lead to this error and, either way, this patch will need to be committed. Note: You will probably need to uninstall and reinstall the module after applying this patch so that it deletes its old settings and the bad data within. That won't break your rules so long as you just reactivate the forms for those rules. If you don't use git or know how to apply patches, this patch simply replaces two lines of code, so it can be done by cutting and pasting if necessary.
If this doesn't fix your issue, are either of you using a development environment where you can add this line of code to the top of the rules_forms.module file?
print_r(variable_get('rules_forms_event_info', array()));- or, if you happen to use Devel moduledsm(variable_get('rules_forms_event_info', array()));- refresh the page, and cut and paste the data that appears at the top of your screen? This will allow me to see exactly how the Rules Forms internal settings are stored, which is what the issue is with this error. Do not do this on a production siteComment #9
jordojuice commentedAll tests pass with this patch:
Also, I opened an issue at #1449936: Write tests to check rules_forms_event_info array structure after enabling forms to write tests to check the structure of the Rules Forms settings array after enabling multiple forms to ensure that this type of error does not occur.
Comment #10
Glenmoore commentedThanks Jordan, works for me.
I think I may be able to help as regards the source of the problem. It may have begun after I uninstalled Drupal Commerce. I think DC automatically enables some of its forms under Rule Forms and so when you install it you get the options in the 'React on Event' dropdown. After I uninstalled it they didnt seem to go away except I was only left with the tail end of the options eg "(blank) is being built", "(blank) is being validated".
Seems obvious now but I hadn't thought of it before.
Many thanks for your help.
Comment #11
jordojuice commentedGreat! Me thinks this can be committed. May have to make a new release since this will probably show up on a lot of installations.
Comment #12
jordojuice commentedCommitted. Since this is a major bug in my opinion I'll be creating a second release candidate. The module seems pretty stable other than this so hopefully we can refrain from creating too many release candidates before a full release.
I'm also committing a fix for this when updating (hopefully) that will check the Rules Forms internal settings and unset any settings that don't have proper form IDs as keys. This should not affect any working settings but should be able to get rid of those bad settings for users who've had this issue without uninstalling and reinstalling the module.
Comment #13
billp44ruby commentedI've downloaded and installed RC2 and no longer am experiencing the error messages. Thanks for the quick turnaround! It also seems to have eliminated the response time issues I was experiencing. Good stuff!
I do have a question related to my use case here... I know it is not a bug or an 'issue', but perhaps you can comment anyway.
I'm using the Rules Form module with Rules and Views, with Exposed Filters and Flags for a product comparison application. In the Views table that I present, the user is permitted to select products by flagging them. They can then click on a link to view a product comparison table. When the user changes their product selection criteria, I want to trim the number of flagged items to 0 because the previously flagged items may no longer be relevant to the selection criteria. I'm using the "Form is Saved" event to execute the 'Trim Flags' action ,and it works fine.
The issue I'm having is that the way exposed filters apparently work is that every time the initial view is loaded, exposed filter settings get automatically saved, which in turn executes the Trip Flag action. This happens now each time the user goes from the product comparison page back to the available products page, even though there have been no changes to the exposed filter settings.
Long story short, is there away I can restrict the Save Form Event triggering to only when the Exposed Filter settings change with Rules Form, or am I going to have to write my own module code to define this event?
Thanks... and thanks again for the quick fix to Rules Form.
Comment #14
jordojuice commentedCan you use the Form element value has changed condition to limit the action to only occur when the Views filter form values have changed? If I'm understanding you correctly, that should be able to do what you want. What Rules Forms does is store the form values in a session variable when the form is built, and that data is used in the condition I mentioned above during validate or submit events to compare the validate/submit form's data with the data that existed when the form was built.
If you end up needing to write a small custom module, the form values for forms with events enabled are stored in
$_SESSION['rules_forms_form_FORM_ID_values']if you want to access them in a form's submit callback or something. However, I intend to change this very soon so all form values are stored in a single session variable in$_SESSION['rules_forms_form_values'][$form_id]so it doesn't clog up the$_SESSIONvariable. In fact, I think I'm going to change that right now.BTW: Thanks for the report and glad we were able to resolve and test it quickly. This wasn't a fringe bug report and that worst thing we can do is cause errors that may be seen on the user side.
Comment #15
billp44ruby commentedUsing "Form element value has changed condition" makes sense. But when I try to implement it as a Condition, all I get is *select* in the Form Element to be targeted pull down menu, so I think I'm missing something. I went back and tried adding "entity has field" conditions, but those fields aren't showing up in the pull down menu. So I guess I'm not getting how to implement it.
Comment #16
jordojuice commentedHmm... there may be another bug in that condition. Let me check it out.
Comment #17
jordojuice commentedThe condition is working fine on forms for me. I can't reproduce this, so the select list is being properly populated. Try revisiting the form or using the "Reset form element information" option for that form and then revisit the form to make sure Rules Forms stores its information. When the form is visited for the first time it should save form element information. But if you're seeing those form elements in other conditions and actions then there may be something else going on.
Comment #18
billp44ruby commentedI've reset the forms, received a "Form elements for [form name] have been built" message, but I'm still not getting any form elements appearing in the Form Element pull down when I try to set a 'when a form element value has changed' condition in Rules.
Comment #19
jordojuice commentedI've been doing some work on the interface and specifically that very condition. I'll try to see if I can figure out why it wouldn't be populating. Is the form element select list in other conditions and actions being populated properly?
Comment #20
billp44ruby commentedI hadn't tried it on any other forms, but I just activated a node form that I use for a special content type and the Form Element select list did not populate for any of the fields in that node form either. Is it possible I'm just setting it up incorrectly? Is there a specific event or other condition that I have to list prior to looking to see if a form value changed?
Comment #21
jordojuice commentedAny Rules Forms event will do - build, validate, or submit (though I wish there were an easy way to block the condition for form built events).
I didn't mean do the elements appear for other forms. I mean, when try to add another Rules Forms condition or action are you able to see the form element names in the list? Is it only when you add Condition: Form element value has changed that you can't see form element names in the list? This can help me narrow it down to either an issue with form element info storage or an issue with that specific condition. So, are the other Rules Forms conditions and actions working well?
Comment #22
billp44ruby commentedOkay. I do get the Form Element pull down list populated on Form Button Was Clicked. For the other two options, I get nothing. I've tried setting all three available Events: Submitted, Built, Validated and "Clicked" is the only thing that puts anything in the Form Element pull down. "Form element has value" and "Form element value has changed" do not populate.
Comment #23
jordojuice commentedThat's really strange because they all use the same exact functions to build the form - in fact, the value changed condition and button clicked condition are set up exactly the same as far as forms and parameters - and the form element information does not vary from condition to condition. Maybe it's a Rules cache issue? You've cleared the cache? Have you tried reinstalling the module and reactivating the forms and what not? It seems this is going to be difficult to track down.
Comment #24
billp44ruby commentedI've done all of those things and still no form elements...