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_formThis 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_expandOur process callback to expand the control.
example_element_phonenumber_validateOur element's validation function.
example_element_themeРеализация hook_theme().
theme_phonenumberTheme function to format the output.
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему