Below is an example of code that makes the first field not required in the form

    function мой_модуль_form_alter(&$form, &$form_state, $form_id){
    $form['field_website']['und'][0]['#required'] = FALSE;


But I need to check the content in the second field after sending the form, and if it coincides with the value of "test", then the first field became not required.

    $form['field_website']['und'][0]['#required'] = FALSE;

1 Answer 1


Use Conditional Fields module.

Your Answer

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

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