简体   繁体   中英

using hook form submit how to stop other functions being called from same submit

Hi sorry about my bad terminology.

Im using drupal

Im using hook form alter and hook form submit to alter data recorded in the sql table.

this is the code

<?php
function mymodule_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
case 'form_id':
 $form['#submit'][] = 'mymodule_form_submit';
  break;
  }
}

function mymodule_form_submit($form, &$form_state) {

$input = db_result(db_query('SELECT MAX(values) FROM {table} WHERE nid = %d', $fid));
$input10 = (($input) ? $input : 0) + 10;
$submit_record = array(
    'nid' => $form_state['values']['nid'],
    'uid' => $user->uid,
    'time' => time(),
    'amount' => $input10,
  );

drupal_write_record('uc_auction_bids', $submit_record);

drupal_set_message(t('Saved %title.', array('%title' => ($input10 submitted))));

}

however, the original values are also being submitted, so im not altering the submit part, just the form. then my submit code and the original is being submitted. So 2 sets of values are being sent to my database.

How can I prevent the original set of values being sent?

Thanks for any help

By doing the following

$form['#submit'][] = 'mymodule_form_submit';

You are adding your submit handler, and not replacing the default submit handler. If you want to replace the default submit handler you should try

$form['#submit'][0] = 'mymodule_form_submit';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM