Hi,

Sorry if my questions sounds newby.
I have read pro drupal development book about how to alter an existing form.
But the book doesn't explain how to alter the submission too.
Does anyone know how to do that?

thx

Comments

If you built your form using

If you built your form using the standard drupal way (eg. drupal_get_form()), you can use a submit function of your own, for example:

if you have a form-building function named mymodule_view_form(), you can use a function named mymodule_view_form_submit() to do the necessary processings..

What particular form are you altering? What changes, or additional action do you want to do upon form submission? It would be easier for people to help you if you provide more specific details on what you want to accomplish..

Hi meric, thx for

Hi meric,
thx for replying

The book gives us an example how to alter login form, which is adding a warning message about login attempts.

function formexample_form_alter($form_id, &$form) {
if ($form_id == 'user_login_block' || $form_id == 'user_login') {
$form['warning'] = array(
'#value' => t('We log all login attempts!'),
'#weight' => -5
);

$form['submit']['#value'] = t('Sign in');
}
}

What about if I want to alter the form by adding an input field 'Sign me as invsible to my online friends'?
In what function I need to perform the action to process the new input field?
Hope this make it clear..:)

Thx

reply

hi i thing u successfully find the solution for alter the form,

Can u share please about alter form,

Tell me i have to write the code in myexample.module file or where

hook_form_alter

Using hook_form_alter is one of the ways you could do that.

Addison wrote an excellent article on altering forms http://www.lullabot.com/articles/modifying-forms-5-and-6

Hi janwari, What I want to

Hi janwari,

What I want to ask is how could I alter the submission process in drupal?
I just wondering, why not drupal also provide hook_form_submit_alter as well as hook_form_alter? :D

thx

There are a lot of steps in

There are a lot of steps in the creation and processing of a form. For the most part, you are generally going to be using hook_form_alter() and hook_nodeapi() to alter this process.

--
Devbee - Open Source Business Solutions - http://devbee.com/

--
Devbee - http://devbee.com/

module_invoke can also be a

module_invoke can also be a good way to be able to do additional work on submission.

try this

rick, maybe you could try this

http://drupal.org/node/58689