filter_form_validate

Versions
4.7 – 6
filter_form_validate($form)

Code

modules/filter/filter.module, line 858

<?php
function filter_form_validate($form) {
  foreach (element_children($form) as $key) {
    if ($form[$key]['#value'] == $form[$key]['#return_value']) {
      return;
    }
  }
  form_error($form, t('An illegal choice has been detected. Please contact the site administrator.'));
  watchdog('form', t('Illegal choice %choice in %name element.', array('%choice' => $form[$key]['#value'], '%name' => empty($form['#title']) ? $form['#parents'][0] : $form['#title'])), WATCHDOG_ERROR);
}
?>

Incorrect?

chris.cohen - Wed, 2009-10-28 10:49

I am not sure the function signature is correct above. In my tests, the function's first argument simply contains the name of the form, whilst the second, currently not shown in the above example, contains the form array itself. I believe it should be more like:

<?php
function filter_form_validate($form_name, $form) {
 
// Do stuff here. $form contains the form array and we can use element_children() on it if we need to.
}
?>

Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.