I've got #1659586: Support Taxonomy term reference fields working apart from error messages from taxonomy_field_is_empty().

Turns out it's because this hook gets some data it probably shouldn't be.

Here's debug output from an entityreference field:

CommentFileSizeAuthor
ief-junk-data-hook_field_is_empty-1.png83.84 KBjoachim

Comments

joachim’s picture

Note that I have *no idea* how 'taxonomy_sport' gets in there. That's probably weirdness at my end.

bojanz’s picture

Tricky.

The is_empty hook is not actually a hook, it is a callback:

function _field_filter_items($field, $items) {
  $function = $field['module'] . '_field_is_empty';

which means we can't override it, and we can't ever give it correct data (since we fill the field only during hook_field_attach_submit).
That code is invoked from two places: field_default_validate() and field_default_submit(), and those two functions always run.

Perhaps we can just make sure that they get NULL or something?
Maybe by having an #element_validate function like inline_entity_form_save_row_weights(), that just does form_set_value($element, NULL, $form_state); ?

(Btw, what's the exact error message? I looked at taxonomy_field_is_empty, didn't see which part would throw the error, since there's an empty() check there...)

joachim’s picture

It complains that there's no 'tid' set in its array.

(BTW, it's hacky, but one think I've done in custom modules for projects is sneakily change $field['module'] in my field widget alter, to then make it come back to me for the callbacks.)

bojanz’s picture

Status: Active » Closed (duplicate)