how can I add a field to a form submission upon submit that will have the same value as the field name "mail" but with the name "email"

2 Answers 2


I think it'll work if you implement hook_form_submit() hook for this form, and in that function set the value of one field to another.


FORM_ID_form_submit($form, &$form_state) {
  $form_state['values']['email'] = $form_state['values']['mail']; 

If your fields are fields of a content then replace the above line with this:

$form_state['values']['email']['und'][0]['value'] = $form_state['values']['mail']['und'][0]['value'];

  • the form submit when i put in this code doesnt seem to be reach. It goes to the page that I have marked as the form action and never gets there.
    – Diana
    Apr 25, 2017 at 20:30
  • this doesnt work for drupal 8
    – Diana
    Apr 25, 2017 at 21:44
  • My bad, didn't realize you were asking for Drupal8. Sorry can't help. Haven't looked into Drupal8 yet.
    – Amir
    Apr 26, 2017 at 21:34

In Drupal 8 I did it this way, there may be a shorter way though


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.