I have looked through multiple tutorials and I don't know what I'm missing.

I have created a new field type using the Field API and it's displaying everything perfectly, but when I try to put information in the textfield and hit save, nothing shows up on the form after the submit and nothing gets put in the database.

Can anyone tell me what I'm missing? Here is an example of the code I've written:

in the module.install file i have:

function cptc_test_field_schema($field) {
 $columns = array(
 'field_test' => array(
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => FALSE,
return array('columns' => $columns);

and in the module.module file i put

function cptc_test_field_info(){
return array(
'field_test'=> array(
  'label' => 'test',
  'description' => 'test crap',
  'default_widget' => 'widget_test',
  'default_formatter' => 'formatter_test',

function cptc_test_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {  
$value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
case 'widget_test':
  $element['widget_test'] = $element + array(
    '#title' => 'Additional Email Addresses',
    '#type' => 'textfield',
    '#default_value' => '',
    '#size' => 60,
$element['#element_validate'][] = 'cptc_test_field_widget_validate';
return $element; 

There's a lot more to it (obviously), but figured that I shouldn't post everything - for expediency's sake. The other hooks I have implemented are:


Thanks in advance!


In your function cptc_test_field_widget_form(), change $element['widget_test'] to $element['field_test']. and make sure your hook_field_is_empty() has the following line of code:

return empty($item['field_test']);

My first thought looking at that is that your widget is defining a textfield, size 60, but your database is only made to hold an integer.

  • I've changed it to a varchar with a length of 255, but no change :\ – belvedere Dec 15 '11 at 15:33
  • 1
    Did you do an uninstall/install? Is the database field a varchar now? – Malks Dec 15 '11 at 23:29
  • Also, have you looked in the error log to see if the database is throwing up any errors? – Malks Dec 15 '11 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.