API page: http://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_pro...
I'm writing a migration from a 3rd party CMS and ran into this issue. When trying to update a node, the values passed in using $form_state['values'] were overwritten to an empty array by the first line in this function:
function drupal_process_form($form_id, &$form, &$form_state) {
$form_state['values'] = array();
After commenting out the line, my API calls were successful, but the UI broke, so I'm assuming somewhere this function is called without $form_state['values'] being set, hence the initial setting. I modified the function to check for the values instead and both API and UI are now working as expected:
function drupal_process_form($form_id, &$form, &$form_state) {
if (!isset($form_state['values'])) {
$form_state['values'] = array();
}
Comments
Comment #1
marcingy commentedIf you are trying to process a node programatical and maintain a form state you should use drupal_form_submit or utilise node_save if you can validate the data.
Comment #2
petermonica commentedThanks, I actually am using drupal_form_submit. The last line of that function calls drupal_process_form, which is where I encountered the error.
Comment #3
petermonica commentedBumping the priority on this. Services module is partially non-functioning due to this error.
Comment #4
cilefen commented