Hi
I've met these errors on the node creating/editing form.
Notice: Undefined index: field_... in reference_option_limit_form_alter() (line 309 of reference_option_limit/reference_option_limit.module).
Warning: Invalid argument supplied for foreach() in reference_option_limit_form_alter() (line 309 of reference_option_limit/reference_option_limit.module).
Notice: Undefined index: field_... in reference_option_limit_form_alter() (line 351 of reference_option_limit/reference_option_limit.module).
These errors appear when there another ajax form elements in the form (i.e. file fields). Function reference_option_limit_form_alter() is called every time ajax request is sent, so it tries to find corresponding field values in $form_state['values'], but the problem is that $form_state['values'] does not contain needed values when form submit event was triggered by other elements.
I think it is needed to add condition at the start of the function reference_option_limit_form_alter() to check if it is needed to perform operations on limited fields.
Patch is coming.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2006798-16.reference_option_limit.ajax-elements.patch | 2.31 KB | joachim |
| #7 | QQ图片20130623195519.jpg | 8.27 KB | bruceci |
| #6 | QQ图片20130623195306.jpg | 12.2 KB | bruceci |
| #4 | 2006798-4.reference_option_limit.file-field.patch | 1.57 KB | webevt |
| #3 | 2006798-3.reference_option_limit.file-field.patch | 1.56 KB | joachim |
Comments
Comment #1
webevt commentedPatch is here, but your review is needed.
Comment #2
metastate commentedPatch got rid of the error for me. Thanks!
Comment #3
joachim commentedThank you both for the patch and the review.
Took me a moment to figure out what this means.
I *think* it's that the AJAX button could in fact not be anything to do with a field, in which case it doesn't have #field_name set on it.
But surely in that case we could bail much earlier on -- before the foreach and before we initialize $flag, no?
Here's a patch with that change. Could someone try it out please?
BTW, a few minor things for future reference:
Patches should be rolled from the module's folder, not your site root.
Remember to trim whitespace from your code before rolling a patch!
Comment #4
webevt commentedThanks for your review. The condition that you mentioned is really can be executed earlier.
The only thing I can add is a "break" statement in the foreach loop, because if we've found the needed element, there's no any reason to go into the next iteration. The patch is here.
Comment #5
joachim commentedThanks! Committed and pushed.
git commit -m "Issue #2006798 by WebEvt, joachim: Fixed error message when other form ajax elements are triggered." --author="WebEvt "
Comment #6
bruceci commentedpatch do not work
file field upload error disapeared , but limited option not work!
Comment #7
bruceci commentedComment #8
bruceci commentedComment #9
joachim commentedIs this the same problem you are reporting here -- #2025975: do not work after update to latest version?
Could you debug to see what has caused the problem?
Comment #10
bruceci commentedI don't know, but I know the condition aways ran in , there is no '#field_name' attribute in the 'trigger_element'.
if(empty($form_state['trigger_element']['#field_name'])){
return;
}
Comment #11
bruceci commentedI installed drupal 7.22 fresh site with reference_option_limit 7.14, but do not work at all。
reference_option_limit 7.13 with no patch is OK!
taxonomy country , taxonomy city, content type location.
city use entity reference to country , location use entity reference to country and city . city field limit by country.
Comment #12
joachim commentedWhat type of widget are you using to trigger?
Comment #13
bruceci commentedI use the normal check box drupal core have。
Comment #14
bruceci commentedHey! I found trigger element with select list widget works fine!
YES! trigger element use checkbox do not work!
may checkbox element state do not have "#field_name"?
Comment #15
joachim commented> may checkbox element state do not have "#field_name"?
Yup. Unfortunately, seems they don't.
It's because when it's a radios or checkboxes element that changes, it's only the *single* checkbox or radio button that comes through as the triggering element.
Comment #16
joachim commentedCould someone try this patch please?
It's working for me with both select and radio widgets, and also with a filefield upload button.
Needs latest from git, as I made some refactoring changes.
Comment #17
socialnicheguru commentedpatch no longer applies
Comment #18
joachim commentedIt applies fine for me on branch 7.x-1.x.
Comment #19
bonchak commentedHello,
is it possible to make this module work with Simple hierarchical select module ?
Comment #20
joachim commentedI'm not actually sure what the latest patch here fixes. I'm able to use filefields and other ajaxy form elements as normal. I think what's being reported in #7 is in fact a new issue: #2182261: doesn't work if controlling field widget is radios.
Comment #21
joachim commentedChanging back to fixed.