How to add a custom field to a taxonomy term I am developing a module and I would like to know how to add a field to a taxonomy term?

My section is named special and I want to add terms in this section

I have this code:

function add($form,&amp;$form_state) {
    $form['name'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('name'),
        '#required' =&gt; TRUE,
    );

    $form['submit_button'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('send'),
    );

    $form['#submit'][] = 'special_add_submit';

    return $form;
}

function special_add_submit ($form, &amp;$form_state) {
    $instance = array(
        'field_name' =&gt; 'nombre',
        'entity_type' =&gt; 'taxonomy_term',
        // This is the vocabulary
        'bundle' =&gt; 'special',
        'label' =&gt; t('Relates to option'),
        'description' =&gt; t('This is the description'),
        'required' =&gt; true,
        'widget' =&gt; array(
        'type' =&gt; 'text_textfield',
        'settings'=&gt; array(
            'max_width'=&gt;80)
        ),
        );
    field_create_instance($instance);
}


How to do that?



i create a field named name when i save that field i want to add the value to taxonomy term named special
$term = Term::create([
  'name' =&gt; 'fashion',
  'vid' =&gt; 'special', 
])-&gt;save();


'fashion' is the new taxonomy item name and 'special' is the existing vocabulary machine name.
The fashion will the taxonomy term under the vocabulary special