API page: http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

I can find this in Examples module:

* Providing a field requires:
* - Defining a field:
* - hook_field_info()
* - hook_field_schema()
* - hook_field_validate()
* - hook_field_is_empty()
*
* - Defining a formatter for the field (the portion that outputs the field for
* display):
* - hook_field_formatter_info()
* - hook_field_formatter_view()
*
* - Defining a widget for the edit form:
* - hook_field_widget_info()
* - hook_field_widget_form()
*

and from examining core field type modules, it looks like these may be optional:

"hook_field_settings_form",
"hook_field_update_field",
"hook_field_update_forbid",

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

There's a group/topic (which this hook is part of) that lists this information, I think:
http://api.drupal.org/api/drupal/modules--field--field.api.php/group/fie...

Usually we just use the @ingroup topicname to point to stuff like this... Is there documentation missing from this page that should be there? Keep in mind also that we don't really put tutorials on api.drupal.org (or in in-code documentation)...

joachim’s picture

What I think this hook should say is something like:

'Along with this hook, the following hooks are also required to define a field type: hook_foo, hook_bar, etc'.

That's not a tutorial, but it's giving essential information that doesn't seem to be there right now.

jhodgdon’s picture

How about something more along the lines of "Along with this hook, you also need to implement other hooks. See (link to topic) for more information."? I don't really want to make a comprehensive list of those hooks there -- it's a long list and I think it's better off on that topic (which can be expanded to explain which hooks are required and which optional).

joachim’s picture

That would work for me.

jhodgdon’s picture

Title: hook_field_info should state which other hooks participate in defining a field type » hook_field_info should have clear link to the field_types topic, and that topic should say which hooks are needed
Status: Postponed (maintainer needs more info) » Active
Issue tags: +Needs backport to D7

Sounds like a plan then. :)

jhodgdon’s picture

Related issue:
#1391118: Clean up Field Types API topic and add settings form hooks
I don't think it's a duplicate though...

chx’s picture

This is still relevant, I just fixed a client's module not implementing _field_is_empty . However, this is not a D8 topic any more, I think... those are plugins now.

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: -Needs backport to D7 +Novice

Given the above description of what needs to be done, it sounds like a good D7 novice patch contributor project.

diego21’s picture

Assigned: Unassigned » diego21
Issue summary: View changes
Status: Active » Needs review
FileSize
655 bytes

I hope this patch fix the issue.

joachim’s picture

Isn't there some sort of magic way to link to a group that doesn't require a hardcoded URL to api.d.org?

jhodgdon’s picture

Status: Needs review » Needs work

Yes, you can link to a group by using the group identifier (what's in the @defgroup or @ingroup) in a @see or @link.

So

+ * @link https://api.drupal.org/api/drupal/modules!field!field.api.php/group/field_types/7 Field Types API @endlink

should be

+ * @link field_types Field Types API @endlink
diego21’s picture

Status: Needs work » Needs review
FileSize
580 bytes

Thanks jhodgdon :-). Didn't know that! I'm gonna learn a lot writing patches ^_^.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

The original bug report said that the field info topic needs more details on which hooks you need, but I'm happy to mark this patch RTBC and move on to expanding the field info topic in a new isssue.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 7.x. I think the field info topic is complete enough for 7.x, but if you don't think so, let's open a separate issue.

joachim’s picture

I think it needs to explain which hooks are needed to define a custom field type. I'll file a new issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.