I’m new to Drupal forms – trying to figure out a maddening problem.
I have a content type of ‘doc-upload’ with various fields including ‘publisher_code’.
When I define the ‘publisher_code’ field type to ‘text’, and go through my upload process, yada yada yada, the value appears in my $node structure later as expected.
When I change ‘publisher_code’ to “field type: List (text), widget: Select list”, and I try to dynamically populate that element with:
function mymodule_form_doc_upload_node_form_alter(&$form, &$form_state) { $publishers = array( 'pub1' => 'Publisher 1', 'pub2' => 'Publisher 2' ); $form['field_publisher_code'] = array( '#title' => t('Select a publisher'), '#type' => 'select', '#options' => $publishers, '#multiple' => FALSE, '#empty_value' => '', '#empty_option' => '- None -', '#required' => TRUE ); }
The form displays properly, but when the form is submitted, the ‘field_publisher_code’ doesn’t come out the other side – presumably it’s getting filtered/invalidated somewhere, but I can’t seem to find where?