I created a module that just uses the hook_form_alter to add additional fields to an existing form. The problem now is when I enter in the information and submit none of the information inputed in the additional fields get saved when I go back to the form.

  • What version of Drupal are you using?
    – sheena_d
    Commented May 2, 2012 at 5:28

1 Answer 1


Other modules aren't generally programmed to be aware of your custom additions and don't know where/how you want to save the data. If you add fields via hook_form_alter() then you should also add your own submit and possibly validation handlers to the form similarly to this:

$form['#validate'][] = 'mymodule_someform_custom_validation';
$form['#submit'][] = 'mymodule_someform_custom_submission';

In the validation handler you can then validate your custom field data (if needed) and in the submit function you should save it. Small amounts of information can be stored in a variable, but if there's bigger amounts of data from different users you'll probably want to create a custom database table where to store all the information in.

  • I think its depend of form, some forms don't need custom submit function and will handled by drupal. in this case we should override exists submit function of this form because it certainly has one... Commented May 2, 2012 at 8:01
  • I'm adding to the Domain Conf Form. I can't find the hook_submission API. Note: This is on Drupal 7
    – meijiOrO
    Commented May 2, 2012 at 15:15
  • @meijiOrO mymodule_someform_custom_validation and mymodule_someform_custom_submission would be the names of your custom form validation and submit handlers (functions) respectively (they are not hooks).
    – Madis
    Commented May 2, 2012 at 15:45

Your Answer

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

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