1

I have a custom model containing two paths. Each path goes to the same function. I wanna to send to each page arguments specific parameter and reception on the function then pass the hidden value to submit function.

  $items['parkingcalculator_normal'] = array(
    'title' => t('Parking calculator'),
    'description' => 'Parking Calculator Page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('parkingcalulator_form',0),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['parkingcalculator_valet'] = array(
    'title' => t('Parking calculator'),
    'description' => 'Parking Calculator Page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('parkingcalulator_form',0 ),
    'access callback' => TRUE,
  );
function parkingcalulator_form($form, &$form_state , $type){...}

but the function does not take the parameter and does not pass the value in the hidden form type to

function parkingcalulator_form_submit($form, &$form_state ,$type)

2 Answers 2

0

Remove $form from the submit function and just keep the $form_state.

The function would look like

function parkingcalulator_form_submit(&$form_state ,$type)
1
  • The Drupal Form API defines the signature for a submit function - you can't just change it at will. This will not work.
    – anonymous
    Nov 29, 2020 at 20:39
0

In parkingcalulator_form($form, &$form_state, $type), create a hidden form element to store the data you need for your submit function:

$form['type'] = array('#type' => 'hidden', '#value' => $type);

Then in your submit function parkingcalulator_form_submit($form, &$form_state) you can access that value:

$type = $form_state['values']['type'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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