I have a content type having 10 fields that are all required. How do I skip validation for some fields? Is there any hook/function that allow me to do this?
I consider that by
How do I skip validation
you mean "make the fields not compulsory" (UI level)
If that is the case then you can use hook_form_alter and change the
setting, for any form element, to
Keep in mind that hook_form_alter is a generic hook invoked by any form in your site (performance issue) alternative you may use hook_form_FORM_ID_alter to "to talk" to a specific form. Hope that helps.
If you want to make the validation on a different level, you have to write your own validation handlers (
['#validate']) or override Drupal's, like
For deciding and skipping some fields after submit follow the following steps.
Step 1: Perform HOOK_form_alter and add a custom function in $form['#validate] array, remember your custom validate function must add on 0th key of the array.
Step 2: Perform your calculation and find on which fields you want to perform the validations, and set them in $form['#limit_validation_errors'].
I hope this will help you for the skipping validation.