gregor171
gregor171

Reputation: 3

How can I modify field value after Drupal webform sumission

I'm trying to modify value of the submitted field with php (server-side) to be send by mail and written to db:

hook_form_alter(&$form, &$form_state, $form_id)

changing of value looks easy, but nothing happens after I change it. Hook works.

Upvotes: 0

Views: 2434

Answers (2)

Rajesh Vishwakarma
Rajesh Vishwakarma

Reputation: 387

First add a submit action in hook_form_alter and second alter the form_state value in form     submission. 

function custom_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'your-webform-id') {
      $form['#submit'][] = 'xyz_form_submit';
    }
}

function xyz_form_submit($form, &$form_state) {
// here you can edit $form_state value before final submit

}

Upvotes: 0

DrColossos
DrColossos

Reputation: 12998

hook_form_alter only manipulates the form before it gets rendered:

Perform alterations before a form is rendered.

Have a look at this API comment, where someone gives a nice example of how to do something after the form has been submitted. There is also a _submit($form, &$form_state) action (the given post from the link points that out) that you need to trigger. You can do all your needed altering there. A little bit more description can be found in the examples from the API

Upvotes: 1

Related Questions