You are here

function _entityform_set_all_nested_props in Entityform 7

Same name and namespace in other branches
  1. 7.2 entityform.admin.inc \_entityform_set_all_nested_props()

Parameters

array $form:

array $props: properties to set

boolean $must_match:

2 calls to _entityform_set_all_nested_props()
entityform_clear_required in ./entityform.admin.inc
Called after_build on entityforms This makes sure that required fields aren't require when saving a Draft. A Draft is not complete so shouldn't enforce required fields
entityform_set_required in ./entityform.admin.inc

File

./entityform.admin.inc, line 400
Entityform editing UI.

Code

function _entityform_set_all_nested_props(&$form, $props, $must_match = FALSE) {
  $matched = TRUE;
  if ($must_match) {
    $matched = isset($form['#entityform_required']);
  }
  if ($matched) {
    foreach ($props as $key => $value) {
      if (isset($form[$key]) && $form[$key] != $value) {
        $form[$key] = $value;
        if (!$must_match) {
          $form['#entityform_required'] = TRUE;
        }
        else {
          unset($form['#entityform_required']);
        }
      }
    }
  }
  foreach (element_children($form) as $key) {
    if (is_array($form[$key])) {
      _entityform_set_all_nested_props($form[$key], $props, $must_match);
    }
  }
}