I have a taxonomy reference field and in the node creation form there will be only one value allowed and I guess I use a radio button and I want it to be enabled by default.
I thought I can do it with form_alter but on inspection in krumo I see the default values are set to the concrete term id.
If I would want to set that id (which I do not know) it could look like:
form['field_abteilung'][LANGUAGE_NONE]['#default_value'] = 12345;
For various users and their roles there will be other another allowed option in this form and I just want to do sth like
form['field_abteilung'][LANGUAGE_NONE].... My-single-radio-button = checked;
Update
I saw I can find out the single option by looking into
$form['field_sektion'][LANGUAGE_NONE]['#options'][2]
I tried it but get an error about missing index 'field_sektion' which confuses me.
update 2 It takes some time, I maybe should have mentioned that the field in the end should be the access control field of https://drupal.org/project/workbench_access , that module also alters the form; I disabled the field's access function first and now need to rebuild all
$form['field_sektion'][LANGUAGE_NONE]['#type'] = 'value';
as long as you have a#default_value
set. Give that a try and if it causes any problems just update the question with the code and I'm sure you'll get it fixed