Alter html output of a term reference form field On my node edit form a term reference field is rendered with the following html output:

&lt;div class="form-item form-type-radio form-item-field-trainingstype-und"&gt;
  &lt;input type="radio" id="edit-field-trainingstype-und-12" name="field_trainingstype[und]" value="12" class="form-radio"&gt;  
  &lt;label class="option" for="edit-field-trainingstype-und-12"&gt;External &lt;/label&gt;
&lt;/div&gt;


As you can see the value attribute is set to 12 which is the term id of that particular item. Now I would like to replace 12 with the term name, External.

So it would look like:

&lt;div class="form-item form-type-radio form-item-field-trainingstype-und"&gt;
  &lt;input type="radio" id="edit-field-trainingstype-und-12" name="field_trainingstype[und]" value="External" class="form-radio"&gt;  
  &lt;label class="option" for="edit-field-trainingstype-und-12"&gt;External &lt;/label&gt;
&lt;/div&gt;


I am unsure which function to use to target this particular field.
I was looking at theme_checkbox() and theme_form_element() but I am uncertain how to proceed and if these are the right functions for the job.

UPDATE:
So I would like to show another field based on the option chosen for the field_trainingstype. In a hook_form_alter I am now doing this:

$form['field_organisaton']['#states'] = array(
  'visible' =&gt; array(
    ':input[name="field_trainingstype[und]"]' =&gt; array('value' =&gt; '12'),
  ),
);


But I would like to trigger this by term name External because the term id might differ per environment.
Doing it that way round will cause problems with the form submission; the value for a term reference field needs to be an integer and throwing a string at it will undoubtedly upset things. You could massage values back into place in a validate function but it seems a bit...messy.

The alternative would be to load the taxonomy term up in the form, so you can use the ID from there:

$terms = taxonomy_get_term_by_name('External', 'vocab_machine_name');
$term = array_shift($terms);
$form['field_organisaton']['#states'] = array(
  'visible' =&gt; array(
    ':input[name="field_trainingstype[und]"]' =&gt; array('value' =&gt; $term-&gt;tid),
  ),
);


That should make it reusable across different environments (provided the vocab only has one term with the name "External").