I've created a custom module for a field in drupal that has two fields, Position and Affiliation. I add the field to my test content, and set Num of Values to "Unlimited".
The Problem:
When I go to create a new instance of test
content, instead of seeing one instance of my field and the "Add another item" button, it starts with two (see image) and the "Add another item" button.
If I set the Num of Values to 1, I only get one. If I click "add another item", it only adds one. I'm looking at my code, and for the life of me cannot figure out where the problem can be. I assume it's something in the widgit.
function pos_aff_select_field_widget_info() {
return array(
'pos_aff_select_widget_default' => array(
'label' => t('Affiliation and Position default widget'),
'description' => t('Drop Down Menu for Affiliation and Position'),
'field types' => array('pos_aff_select'),
'behaviors' => array(
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
'default value' => FIELD_BEHAVIOR_DEFAULT,
),
),
);
}
function pos_aff_select_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element){
$base = $element;
if($instance['widget']['type'] == 'pos_aff_select_widget_default') {
$element['position'] = array(
'#type' => 'select',
'#title' => t('Position'),
'#default_value' => isset($items[$delta]['position']) ? $items[$delta]['position'] : NULL,
'#options' => pos_aff_select_query("ibs_position"),
);
$element['affiliation'] = array(
'#type' => 'select',
'#title' => t('Affiliation'),
'#default_value' => isset($items[$delta]['affiliation']) ? $items[$delta]['affiliation'] : NULL,
'#options' => pos_aff_select_query("ibs_affiliation"),
);
}
return $element;
}
Does anyone have any clue what is going wrong?