hook_field_widget

  1. drupal
    1. drupal7
Versionen
drupal7 hook_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0)

Return a single form element for a form.

It will be built out and validated in the callback(s) listed in hook_elements. We build it out in the callbacks rather than in hook_field_widget so it can be plugged into any module that can provide it with valid $field information.

Field API will set the weight, field name and delta values for each form element. If there are multiple values for this field, the Field API will call this function as many times as needed.

Übergabeparameter

$form The entire form array, $form['#node'] holds node information. TODO: Not #node any more.

$form_state The form_state, $form_state['values'][$field['field_name']] holds the field's form values.

$field The field structure.

$instance The field instance.

$items Array of default values for this field.

$delta The order of this item in the array of subelements (0, 1, 2, etc).

Rückgabewert

The form item for a single element for this field.

Verwandte Themen

Code

modules/field/field.api.php, line 426

<?php
function hook_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
  $element = array(
    '#type' => $instance['widget']['type'],
    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
  );
  return $element;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen