You are here

function cck_table_field_widget_form in CCK Table Field 7

Same name and namespace in other branches
  1. 8 cck_table.module \cck_table_field_widget_form()

Implements hook_field_widget_form().

File

./cck_table.module, line 191
Defines a field type that outputs data in a table.

Code

function cck_table_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {

  // it suggest I use += to avoid overwriting incoming $element & $element as parameter instead of $base
  // if I do this it throws error of undefined operand type
  // if I do this then I cannot put in default help
  if (!empty($instance['description'])) {
    $description = t($instance['description']);
  }
  else {
    $description = t(_cck_table_default_help_text($instance['display']['default']['type'], $instance['widget']['settings']['enforce_misalign_col']));
  }
  $element = $base;
  $element['table'] = array(
    '#type' => 'textarea',
    '#title' => check_plain($element['#title']),
    '#default_value' => isset($items[$delta]['table']) ? $items[$delta]['table'] : NULL,
    '#rows' => $instance['widget']['settings']['rows'],
    '#description' => $description,
  );
  return $element;
}