I'm getting the following notice on the node creation form page for a node I defined in a module .install file.

Notice: Undefined index: max_length in text_field_widget_form() (line 512 of /home/ben/www/madlib7.dev/modules/field/modules/text/text.module).

It appeared after I changed a text field into a text_long field. I'm not sure what I'm doing wrong and have struggled navigating the documentation of D7 fields. Anyone have any advice? Here are the arrays I'm passing to field_create_field() and field_create_instance(). I'll include that aswell.

// From inside madlib_install()
  foreach (_template_installed_fields() as $field) {
    field_create_field($field);
  }

  foreach (_template_installed_instances() as $instance) {
    $instance['entity_type'] = 'node';
    $instance['bundle'] = $madlib_template['type'];
    field_create_instance($instance);
  }


/**
 * Returns a structured array defining the fields created by this content type.
 */
function _madlib_installed_fields() {
  $t = get_t();
  return array(
    'madlib_tokens' => array(
      'field_name' => 'madlib_tokens',
      'cardinality' => 1,
      'type' => 'text_long',
    ),
    'madlib_template_id' => array(
      'field_name' => 'madlib_template_id',
      'cardinality' => 1,
      'type' => 'text',
    ),
  );
}

/**
 * Returns a structured array defining the instances for this content type.
 */
function _madlib_installed_instances() {
  $t = get_t();
  return array(
    'madlib_tokens' => array(
      'field_name' => 'madlib_tokens',
      'label' => $t('Token string of word types.'),
      'widget' => array(
        'type' => 'text_textfield',
      ),
      'display' => array(
        'madlib_list' => array(
          'label' => 'hidden',
          'type' => 'hidden',
        ),
      ),
    ),
    'madlib_template_id' => array(
      'field_name' => 'madlib_template_id',
      'label' => $t('ID of the madlib being used.'),
      'widget' => array(
        'type' => 'text_textarea',
      ),
      'display' => array(
        'madlib_list' => array(
          'label' => 'hidden',
          'type' => 'hidden',
        ),
      ),
    ),
  );
}

Comments

BenW’s picture

Eh, never mind. I put the textarea in the wrong instance definition.