You are here

function conditional_fields_find_required_field in Conditional Fields 5

Recursive function finds if a field is required If it is required, it unsets the #required value, themes a mock required markup, sets a #required_field value, and returns TRUE. If $is_unset is TRUE, the functions finds a #required_field value, and returns the field.

2 calls to conditional_fields_find_required_field()
conditional_fields_node_editing_form in ./conditional_fields.module
Alteration of the node editing form
conditional_fields_node_editing_form_validate in ./conditional_fields.module
Validation for node editing form.

File

./conditional_fields.module, line 614

Code

function conditional_fields_find_required_field(&$field, $is_unset = FALSE) {
  if ($field['#required'] && !$is_unset) {
    $field['#required'] = FALSE;
    $field['#required_field'] = TRUE;
    return TRUE;
  }
  else {
    if ($field['#required_field']) {
      $field['#required'] = TRUE;
      return $field;
    }
    else {
      foreach (element_children($field) as $child) {
        return conditional_fields_find_required_field($field[$child]);
      }
    }
  }
  return FALSE;
}