1

I have gotten my validation module to kind of work, I have this:

function product_id_form_validate($form, &$form_state) {

if($form_state['node']->field_product_id['und']['0']['value'] == '123'){
    form_set_error('field_product_id', 'Product ID: is taken');
}

}

But when I change the value in field_product_id the value doesn't change upon save, it stays the same as when I first entered the form. Is there a function I need to call to say, when I click save look at this field again?

Thanks

2

Submitted values are stored in the $form_state['values'] array so you need to test that instead:

if ($form_state['values']['field_product_id'][LANGUAGE_NONE][0]['value'] == '123') {
  ...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.