I have created a custom module. Show me an error when I want to enable my custom module. The error is -
FieldException: Attempt to create field name windfarm_unit_count which already exists and is active. in field_create_field() (line 85 of \modulebuilt\modules\field\field.crud.inc).
//create fields
$fields = array();
$fields['windfarm_unit_count'] = array(
'field_name' => 'windfarm_unit_count',
'type' => 'number_integer',
//optional
'cardinality' => 1,
'settings' => array(
'max_length' => 5,
)
);
$fields['windfarm_latitude'] = array(
'field_name' => 'windfarm_latitude',
'type' => 'number_float',
'settings' => array(
'max_length' => 20,
)
);
$fields['windfarm_turbine_manufacturer'] = array(
'field_name' => 'windfarm_turbine_manufacturer',
'type' => 'text',
'settings' => array(
'max_length' => 60,
)
);
foreach ($fields as $field) {
field_create_field($field);
}
//create field instances
$instances = array();
$instances['windfarm_unit_count'] = array(
'field_name' => 'windfarm_unit_count',
'label' => $t('Number of Units'),
'desription' => $t('Number of Individual unit at a given facility'),
'widget' => array(
'type' => 'text_textfield',
),
'required' => TRUE,
'settings' => array(
'text_processing' => 0,
),
);
$instances['windfarm_latitude'] = array(
'field_name' => 'windfarm_latitude',
'label' => $t('Latitude'),
'desription' => $t('Signed degrees formate (DDD.dddd)'),
'widget' => array(
'type' => 'text_textfield',
),
'settings' => array(
'text_processing' => 0,
),
'display' => array(
'default' => array(
'type' => 'hidden',
),
),
);
$instances['windfarm_longitude'] = array(
'field_name' => 'windfarm_longitude',
'label' => $t('Longitude'),
'desription' => $t('Signed degrees formate (DDD.dddd)'),
'widget' => array(
'type' => 'text_textfield',
),
'settings' => array(
'text_processing' => 0,
),
'display' => array(
'default' => array(
'type' => 'hidden',
),
),
);
$instances['windfarm_turbine_manufacturer'] = array(
'field_name' => 'windfarm_turbine_manufacturer',
'label' => $t('turbine manufacturer'),
'desription' => $t('The name of the turbine manufacturer'),
'widget' => array(
'type' => 'text_textfield',
),
'display' => array(
'default' => array(
'label' => 'inline',
),
),
);
foreach ($instances as $instance) {
$instance['entity_type'] = 'node';
$instance['bundle'] = 'windfarm';
field_create_instance($instance);
}
}
Active
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.