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'] : '';
switch($instance['widget']['type']){
case 'widget_test':
$element['widget_test'] = $element + array(
'#title' => 'Additional Email Addresses',
'#type' => 'textfield',
'#default_value' => '',
'#size' => 60,
);
break;
default:
break;
}
$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:
hook_field_is_empty
hook_field_validate
hook_field_widget_error
hook_test_field_widget_info
hook_test_field_widget_validate
hook_test_field_formatter_info
hook_test_field_formatter_view
Thanks in advance!