example_element.module
Версия 1.4 (checked in on 2007/10/05 at 16:42:46 by drewish)
This is an example demonstrating how a module can define custom form elements.
Form elements are already familiar to anyone who uses Forms API. Examples
of core form elements are 'textfield'
, 'checkbox'
and 'fieldset'
. Drupal
utilizes hook_elements()
to define these FAPI types, and this occurs in
the core function system_elements()
.
Each form element has a #type value that determines how it's treated by
the Form API and how it's ultimately rendered into HTML. hook_elements()
allows modules to define new element types, and tell the Form API what
default values they should automatically be populated with.
By implementing hook_elements in your own module, you can create custom form elements with their own properties, validation and theming.
In this example, we will define a phone number field that is expanded into several text fields for area code, phone number and extention, each of which is validated.
Функции
Имя | Описание |
---|---|
example_element_demo_form | This is a simple form to demonstrate how to use the phonenumber element we've defined. |
example_element_elements | Реализация hook_elements(). |
example_element_menu | Реализация hook_menu(). |
example_element_phonenumber_expand | Our process callback to expand the control. |
example_element_phonenumber_validate | Our element's validation function. |
example_element_theme | Реализация hook_theme(). |
theme_phonenumber | Theme function to format the output. |