You are here

function matrix_widget in Matrix field 6.2

Same name and namespace in other branches
  1. 5 matrix.module \matrix_widget()
  2. 6 matrix.module \matrix_widget()

Implementation of hook_widget().

File

./matrix.module, line 387
Defines simple matrix field types.

Code

function matrix_widget(&$form, &$form_state, $field, $items, $delta = 0) {
  switch ($field['widget']['type']) {
    case 'table':
      $element = array(
        '#type' => 'matrix_table',
      );
      break;
    case 'matrix':
      $element = array(
        '#type' => 'matrix_matrix',
        '#default_value' => isset($items[$delta]) ? $items[$delta] : $form_state['post'][$field['field_name']][$delta][0],
      );
      break;
  }
  return $element;
}