I want to take the content of a textarea and process it with a php function in my module when a user clicks submit in a form.

How do I do this? There doesn't seem to be a #callback attribute to set for the submit button according to the form api, or have I missunderstood?

Comments

tce’s picture

I think you need to use a submit handler in hook_form_alter

<?php
$form['#submit'][] = 'callback_form_submit';
?>

then in the callback you can manipulate the textarea

<?php
function callback_form_submit($form, &$form_state) {
  // find the textarea value in $form_state['values]
}
?>
numfar85’s picture

So you can't add it directly in the form builder function?

numfar85’s picture

Oh, and also I have the function _molmeth_add_form_submit() which should be run after the callback function if certain requirements are met. Will this be possible to configure in the callback function or somewhere else?

numfar85’s picture

Problem is solved.