1

I would like to pass arguments from the code.

`$form['td_deals']['fetch_deals'] = array(
    '#type' => 'submit',
    '#value' => t('Fetch Deals'),
    '#weight' => 45,
    '#submit' => array('td_import_fetch'),
  );`

The submit in the form calls a function td_import_fetch, i would like to pass another argument (A variable ) in that array. is it possible?

2

2 Answers 2

0

If the variable's value's coming from a form then you should be able to grab the value straight from $form_state within a submit handler.

Your submit handler function needs to take 2 arguments, $form and &$form_state (by reference). The values currently set in the form can be found in $form_state['values'] array.

2

I assume you want to pass some data not entered by user. You can use hidden fields for that and when user submits his data you will get that field data as well and if you are bothered about tampering of data you can use #access to make sure its not tampered with.

Your Answer

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