Hi folks,

I am newbie in Drupal, and seeking some help for form submission to custom URL.

I have been trying to submit a form to a custom URL via AJAX.
But i am not sure why form_validate and form_submit handlers are not executing?

What are the possible things which i might doing wrong?

Note: I am not using the Drupal AJAX api, rather i am submitting the form by custom AJAX stuffs.

Sample code:

function cf_menu() {
// A menu callback is required when using ajax outside of the Form API.
$items['cf/save-folder'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('cf_folder_form'),
'access arguments' => array('access content'),
);
return $items;
}

function cf_folder_form($form, &$form_state) {
$form['folder_name'] = array(
'#type' => 'textfield',
'#title' => t('Folder Name'),
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);

$form['#action'] = 'cf/save-folder';
return $form;
}

function cf_folder_form_validate($form, &$form_state) {
// form validation
}

function cf_folder_form_submit($form, &$form_state) {
// form submission
}

In template file, i am rendering the form as :
print drupal_render(drupal_get_form('folder_form'));

Thanks

-Imran

Comments

I have identified the

I have identified the problem.

The form's build_id and form_token values are incorrect.

I am not able to understand why form_id, form_build_id and form_token values are rendering incorrect?

Any guess, what i am missing?

Thanks

-Imran