I want to create a page that contains 2 different forms, that use URL arguments. Each part of this task is solved easily when done separate. I can use URL parameters on a form, using drupal_get_form as callback:
function mymodule_menu() {
$items['user/%/blah'] = array(
'title' => 'Blah',
'page callback' => 'drupal_get_form',
'page arguments' => array('my_custom_callback', 1),
'access arguments' => TRUE,
);
}
function my_custom_callback($form, &$form_state, $uid) {
// I can use candidateId here now
}
What else could be done is, create a custom page callback with two forms (not completely sure if this works)
function mymodule_menu() {
$items['user/%/blah'] = array(
'title' => 'Blah',
'page callback' => 'my_page_callback',
'page arguments' => array(1),
'access arguments' => TRUE,
);
}
function my_page_callback($uid) {
$build = array();
global $user;
//PROBLEM: I can't pass the URL parameters to the separate
//form callbacks
$build['form1'] = drupal_get_form('form1_callback');
$build['form2'] = drupal_get_form('form2_callback');
return $build;
}
So as described in the comment, I can't pass the URL parameters to the separate form callbacks - and they need this parameter in my module. Precisely: I need 2 Forms on one page (because I need 2 different submit buttons that work as default buttons), with an URL parameter passed each.
TL;DR:
Basically, I need a form page that has 2 text input fields, and each field should have an own, separate submit button - but both should be default buttons on it's field, so it can easily be used without the mouse, just by filling in the input field & pressing enter. The corresponding button of the field should be triggered.
I don't care if I need 1 or 2 forms, I just need the URL parameter on both forms.
Solutions that did not help:
...and others I found.
Thanks in advance.