Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you need to have the entityreference field required (for times when you also have submissions without a prepopulated url) the submission fails with a form_set_error on the field as if it were empty (though it was prepopulated correctly).
I can't figure out how to fix it yet to submit a patch, but I at least wanted to get it reported.
Comments
Comment #1
jyee CreditAttribution: jyee commentedI'm experiencing something similar, however it seems to depend on other fields in the form.
For example, I have a multiple value file field in my form. When a user submits the form with one file, the form submits correctly. When a user submits with two files, the form returns a "field X is required" error.
Comment #2
ezheidtmann CreditAttribution: ezheidtmann commentedI am also experiencing problems of a similar nature, in an interaction with og_role_field. I'll update here when I find out what's going on.
Comment #3
ezheidtmann CreditAttribution: ezheidtmann commentedIn my situation, the problem is that og_role_field needs to access the $items array for the og_group_ref field in the validation step, but entityreference_prepopulate doesn't get involved until after validation, when insertion is about to happen.
Working on a fix.
Comment #4
ezheidtmann CreditAttribution: ezheidtmann commentedI resolved my issue by calling
entityreference_prepopulate_get_values_from_url()
inog_role_field_field_validate()
. It's super ugly, but right now I don't have the time or patience to wade through the field & form APIs to find the proper fix.The proper fix would probably involve adding a #process callback for entityreference_prepopulate when it is enabled, or a validation callback.
Comment #5
gthing CreditAttribution: gthing commentedI'd call this critical since it creates a situation where the entity reference field doesn't work.
Any progress on a fix or workaround?
Comment #6
ezheidtmann CreditAttribution: ezheidtmann commentedHey gthing, if you're experiencing this problem, could you provide more information on your situation? What values are you prepopulating in your entityreference field? What other modules are in use?
Comment #7
ezheidtmann CreditAttribution: ezheidtmann commentedjyee: Is your issue possibly related to this one? #1502972: Issues with ajax file upload fields
Comment #8
gthing CreditAttribution: gthing commentedezheidtmann: Thanks for your response. Your link to jyee was exactly the problem I'm having. I'll update to the latest version.
Comment #9
howards CreditAttribution: howards commentedI was having the same issue and ran across #1958800: AJAX causes entityreference_prepopulate_get_values_from_url to fail and it appears to fix the issues. Try that!