taxonomy_vocabulary_create_field
- Versions
- 7
taxonomy_vocabulary_create_field($vocabulary)
Create a default field when a vocabulary is created.
Parameters
$vocabulary A taxonomy vocabulary object.
Code
modules/taxonomy/taxonomy.module, line 434
<?php
function taxonomy_vocabulary_create_field($vocabulary) {
$field = array(
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
'type' => 'taxonomy_term',
// Set cardinality to unlimited so that select
// and autocomplete widgets behave as normal.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
'vid' => $vocabulary->vid,
'parent' => 0,
),
),
),
);
field_create_field($field);
}
?>Login or register to post comments 