Drupal 6: Only inserting first character of value to MySQL

rarriaccica

New Member
I am working with a hook_form_alter on a CCK type (for you drupal-ers). I have a field that is normally a select list in my node form. However, in this instance, I want to hide the select list, and populate its value in the form with an SQL query. Everything was going nicely. I could see that my desired value was showing up in the HTML source, so I knew my query was executing properly. However, when I submit the form, it only inserts the first character of the value. A few of my tests were values of 566, 784, 1004 - the column values were 5,7,1, respectively. At first I thought it had to be the DB column attributes, but when I removed my form_alter that makes the field hidden and select the value manually, the correct value is inserted?!?\[code\] <?phpfunction addSR_form_service_request_node_form_alter(&$form, $form_state) { if (arg(0) == 'user' && is_numeric(arg(1))) { $account = arg(1); $club = 2589; $form['field_sr_account'] = array( '#type' => 'hidden', '#value' => $club ); }}?>\[/code\]Can anyone see why only the first character would be inserted??Note: I have tried deleting and recreating the column, using #value & #default_value, and it is still submitting only the first character of the integer. Also, I eliminated the submit handler as a possible cause by removing it, which still resulted in only one character being submittedMore Updates - Still Searching! Okay, some good questions. Allow me to answer them:[*]The DB column type is integer(4)[*]The HTML the hook produces is :input type="hidden" name="field_sr_account" id="edit-field-sr-account" value="http://stackoverflow.com/questions/2035097/2589" Latest Update: I think the issue has been narrowed to the structure of the array. When I do var_dump on this field after the form alter has been processed, this is what I get..\[code\][43] => Array ( [#type] => hidden [#default_value] => 2589 [#post] => Array ( ) [#programmed] => [#tree] => [#parents] => Array ( [0] => field_sr_account ) [#array_parents] => Array ( [0] => field_sr_account ) [#weight] => 0.016 [#processed] => 1 [#description] => [#attributes] => Array ( ) [#required] => [#input] => 1 [#process] => Array ( [0] => form_expand_ahah ) [#name] => field_sr_account [#id] => edit-field-sr-account [#value] => 2589 [#defaults_loaded] => 1 [#sorted] => 1 )\[/code\]What is the structure of the field that I can set the form value to. It's gotta be something like what abhaga is suggesting..
 
Back
Top