Search code examples
drupal-7validationform-api

form_set_value() does not work during validation for webform


I have a webform, and a custom validation function. Which both work fine.

But when I do a form_set_value inside the validation function, nothing happens.

Can anyone help me out please

function test_webservices_validate(&$form, &$form_state) {

    if (form_get_errors())
        return;
    $form_values = $form_state['values']['submitted'];

    $Address = _test_webservices_translate($values);
    if (!$Address->succes) {
            form_set_value($form['submitted']['voornaam'], 'sdfdsfsd', $form_state);
            dpm($form);
            dpm($form_state);
    } else {
        _test_webservices_handledcm($form, $form_state, $Address);
    }
}

Solution

  • Ok,

    What happens is when going trough the flow, somewhere in one of the functions the variables are not passed as a reference, so you actually loose the information you changed. I fixed this by changing core functionality and passing the object as a reference.