I have a simple form with method GET as follow...
function MYMODULE_form($form, &$form_state) {
$form['#method'] = 'get';
$params = drupal_get_query_parameters();
$form['cat'] = array(
'#type' => 'select',
'#title' => t('Categories'),
'#options' => $categories,
'#default_value' => isset($params['cat']) ? $params['cat'] : '',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
}
GET actuly bypasses the default submit and validation functions, which is ok for me. I want to submit this form without submit button, when value in 'Categories' field is changed.
function MYMODULE_form($form, &$form_state) {
$form['#method'] = 'get';
$params = drupal_get_query_parameters();
$form['cat'] = array(
'#type' => 'select',
'#title' => t('Categories'),
'#options' => $categories,
'#default_value' => isset($params['cat']) ? $params['cat'] : '',
'#ajax' => array(
'callback' => 'MYMODULE_form_submit',
),
);
}
How should I do this?