You are here

function apachesolr_mlt_block_form_validate in Apache Solr Search 5

function apachesolr_mlt_block_validate()

Perform basic form field validation on the morelikethis fields

Parameters

string $form_id the form ID:

array $form_values an array of from values:

File

contrib/apachesolr_mlt/apachesolr_mlt.module, line 237

Code

function apachesolr_mlt_block_form_validate($form_id, $form_values) {
  if ($form_id == 'apachesolr_mlt_block_form') {
    foreach ($form_values as $key => $value) {

      //make sure the user inputed a number, accept for the field list
      if (strpos($key, 'mlt_') === 0 && $key != 'mlt_fl') {
        if (!empty($value) && !is_numeric($value)) {
          form_set_error($key, t("This field must contain a whole number."));
        }
      }
    }
  }
}