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?

  • Do you want that to decide after submission or before submission?
    – Shubham
    Dec 21, 2015 at 11:51
  • After save button clicked. Dec 21, 2015 at 12:27
  • you can edit the required field and change it's setting.
    – WaQaR Ali
    Dec 21, 2015 at 13:07
  • @WaQaR Ali fields are depend on other value, so I cant not change this form settings. Dec 21, 2015 at 13:12
  • then you should follow the hook_form_alter as written in below answer.
    – WaQaR Ali
    Dec 21, 2015 at 13:23

2 Answers 2


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 ['#required'] setting, for any form element, to FALSE.

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 node_form_validate


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.

  • I have to skip some required fields value based on other required value. This will checked run time once user clicked on save button. Dec 23, 2015 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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