drupal6 error ajax inline

136 views Asked by At

How can i set a custom inline error messages to form in a node (include cck and all the stuff) ?

I saw several modules, but none of them give a 100% solution, because there is no CCK-support, upload-support, error messages etc.

1

There are 1 answers

0
alxp On

I'm guessing you are looking to do custom validation on a CCK field?

In that case you can add your function by creating a module and implementing hook_form_alter() and creating your own validation function.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'story_node_form': // Or whatever content type you're checking
      // Simply add an additional link validate handler.
      $form['#validate'][] = 'mymodule_field_validate';
      break;
  }
}

function mymodule_field_validate($form, &$form_state) {
  if (!somevalidatorfunctionorother($form_state['values']['my_custom_field']) {
    form_set_error('my_custom_field', t('Text of your error message.'));
  }
}

I adapted the code above from this post: http://fleetthought.com/adding-additional-cck-validation-function-field-using-hookformalter