This example demonstrates how to use the field types API.
This has been updated from Barry Jaspan's presentation at DrupalCon Paris 2009.
Providing a field requires:
- Defining a field:
- Defining a formatter for the field (the portion that outputs the field for display):
- Defining a widget for the edit form:
Our module defines the field in field_example_field_info(), field_example_field_validate() and field_example_field_is_empty(). field_example_field_schema() is implemented in field_example.install.
Our module sets up a formatter in field_example_field_formatter_info() and field_example_field_formatter_view(). These are the API hooks that present formatted and themed output to the user.
Finally, our module defines the widget in field_example_field_widget_info() and field_example_field_widget_form(). The widget is the form element used to receive input from users when the field is populated.
See also
Parent topics
File
- modules/
examples/ field_example/ field_example.module, line 7 - Hook implementations for the Field Example module.
Functions
Classes
Name | Location | Description |
---|---|---|
FieldExampleTest |
modules/ |
Functional tests for the Field Example module. |