How can I modify field value after Drupal webform sumission
I'm trying to m开发者_如何学Goodify 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.
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
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
}
精彩评论