validation - How to replace field value in a Drupal Webform's validator? -
validation - How to replace field value in a Drupal Webform's validator? -
in drupal webform, i'd alter submitted value (e.g. strip non-numeric character) when going through validator.
i follow validator readme add together in hook_webform_validation_validators
, implement hook_webform_validation_validate
hook. cannot locate homecoming parameter alter submitted webform value.
for example, if user enters $12,340
, i'd fail submission , update webform value 12340
.when user submits sec time, new value 12340
pass validator , saved.
i don't think webform validation module allows alter submitted values. i've looked @ how implements validation , can similar in own module if want alter submitted value.
the next code taken in part http://fleetthought.com/adding-additional-cck-validation-function-field-using-hookformalter , webform validation module code.
function your_module_name_form_alter(&$form, &$form_state, $form_id) { if (strpos($form_id, 'webform_client_form_') !== false) { // add together additional link validate handler. $first = array_shift($form['#validate']); array_unshift($form['#validate'], $first, 'form_alterations_link_validate'); } } function form_alterations_link_validate($form, &$form_state) { // access submitted values through $form_state['values']['submitted'] }
in form_alterations_link_validate
, can utilize drupal's form_set_value()
method alter submitted form values during form validation.
validation drupal drupal-webform
Comments
Post a Comment