I'm way out of my depth here, but having $form in validateAutocompleteInput is causing problems using field_group_multiple (FGM). FGM has a validation wrapper doing callbacks with arguments $element and $form_state.

I've checked other validation functions and it seems the standard is to only use those two arguments. However, _entityreference_autocomplete_tags_validate, calling validateAutocompleteInput, uses three arguments; $element, &$form_state and $form.

I've looked at places where validateAutocompleteInput is used and it seems $form is never used for anything.

So, attached is a patch that refactors out $form from all validation functions.

It solves the issue with FGM and I can see no adverse effects.

Do we need $form?

Comments

odegard created an issue. See original summary.

odegard’s picture

Title: Remove $form from validateAutocompleteInput » Remove $form from validation
odegard’s picture

odegard’s picture

Priority: Normal » Minor
Status: Needs review » Needs work
StatusFileSize
new4.02 KB

Simple reroll to adjust line number to 1.4.

I've become a (small) bit wiser since last time and I see now that entityreference implements hook_validate correctly. It's the internal validateAutocompleteInput that has an extra parameter, which should be fine, only it isn't when using field group multiple. I don't like this patch but I need it until I've removed field group multiple and using completely custom fields instead.

Not sure what status to give this. I'm not sure it should go in to entityreference anymore, setting to "needs work". Closed won't fix would probably also work. Feel free to change status.