Example: Field Types API
Same name in other branches
- 3.x modules/field_example/field_example.module \field_example
- 4.0.x modules/field_example/field_example.module \field_example
Examples using Field Types API.
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.
And 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 the user when the field is being populated.
See also
Parent topics
File
-
field_example/
field_example.module, line 7
Functions
Title Sort descending | File name | Summary |
---|---|---|
field_example_3text_validate | field_example/ |
Validate the individual fields and then convert to RGB string. |
field_example_field_formatter_info | field_example/ |
Implements hook_field_formatter_info(). |
field_example_field_formatter_view | field_example/ |
Implements hook_field_formatter_view(). |
field_example_field_info | field_example/ |
Implements hook_field_info(). |
field_example_field_is_empty | field_example/ |
Implements hook_field_is_empty(). |
field_example_field_schema | field_example/ |
Implements hook_field_schema(). |
field_example_field_validate | field_example/ |
Implements hook_field_validate(). |
field_example_field_widget_error | field_example/ |
Implements hook_field_widget_error(). |
field_example_field_widget_form | field_example/ |
Implements hook_field_widget_form(). |
field_example_field_widget_info | field_example/ |
Implements hook_field_widget_info(). |
field_example_menu | field_example/ |
Implements hook_menu(). |
_field_example_page | field_example/ |
A simple page to explain to the developer what to do. |
Classes
Title Sort descending | File name | Summary |
---|---|---|
FieldExampleTest | field_example/ |
Functional tests for the Field Example module. |