In a module, I am using the following code.
function mysimple_form($form, &$form_state) {
$form['#method'] = 'get';
$form['#action'] = '/buy/{_val_}';
$form['search_location'] = array(
'#type' => 'textfield',
'#title' => 'Search',
'#default_value' => t('kathmandu'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#attributes' => array(
'placeholder' => t('Search')
)
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
$form['#submit'][] = 'mysimple_form_submit';
return $form;
}
function mysimple_form_submit($form, &$form_state) {
krumo('asdsads');
die();
}
I am using that form in hook_node_view()
.
function mymodule_node_view($node, $view_mode, $langcode) {
$form = drupal_get_form('mysimple_form');
$node->content['simpleform'] = array(
'#weight' => -1,
'#markup'=> drupal_render($form)
);
}
The form is displayed perfectly, but the callback function doesn't seem to work.
I also tried $form['actions']['#submit][] = 'mysimple_form_submit';
and $form['actions']['submit']['#submit][] = 'mysimple_form_submit';
but the form submission handler is still not invoked.
die();
?