0

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

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

$form['test']['und'][0]['value']=test;

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.

if($form['test']['und'][0]['value']=='test'){
    $form['field_website']['und'][0]['#required'] = FALSE;
}
1

Use Conditional Fields module.

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.