2

I feel like I'm retarded but when I read the page at api.drupal.org I'm still wondering what the point is of the function. It says 'Define what constitutes an empty item for a field type'. I'd expect that this function would put NULL there if a value wouldn't be present, but it doesn't look like this is happening.

Also: is it required to write this function in my .module file to get a fieldname in my drop-down list of the Manage Fields page (you know, as a babystep)

1 Answer 1

4

I think it's used for fields that can accept multiple values, to determine whether or not the last item in the list has been filled out, or is in the 'new' state without having been filled out.

If this function didn't exist the field API wouldn't be able to make a distinction between what is classed as a filled-in row, and what is a 'New' row that hasn't been filled out, and for which the values should not be saved.

It can also be used to ensure that a minimum of columns in a field are filled out before it's classed as a save-able value.

If I remember rightly the hook is 'required' for modules that provide a field, so I'm not sure if you'll get away with leaving it out.

You could easily just implement it and return a TRUE or FALSE though for testing purposes.

3
  • 1
    Hah, was writing pretty much the same thing, you were a minute or so faster ;) Commented Jun 27, 2012 at 15:33
  • Heh heh, it's all the coffee that's in me today...I'm getting things done like a twitchy rocket! Commented Jun 27, 2012 at 15:37
  • @Clive, thanks for the explaination, is there any way I can override hook_field_is_empty() drupal.stackexchange.com/questions/257507/… Commented Mar 12, 2018 at 4:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.