I have a simple form with a selection menu on the node display page. Is there an easy way to check the form in my callback function? When checking, I do not mean anything advanced, just to check if the values ββreally existed in the array of forms. For example, without ajax, if there are 3 elements in my selection menu, and I add the 4th element and try to submit the form, drupal throws an error saying something like "illegal selection, please contact the administrator".
With ajax, this 4th item you created will be saved to the database. So I have to write a confirmation, for example
if ($select_item > 0 && $select_item <= 3) {
}
Or is there an easier way to check if an element really existed in an array of forms? I hope that since without ajax, drupal will not present the form if it were manipulated. Thank.
EDIT:
So I need this in my callback function?
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$form['#programmed'] = $form['#redirect'] = FALSE;
drupal_process_form($form_id, $form, $form_state);
To get $ _POST ['form_build_id'], I sent it as a data parameter, right? Where I use form_get_cache, it looks like there is no data. Now lost.
source
share