You are here

function _field_collection_collect_required_elements in Field collection 7

1 call to _field_collection_collect_required_elements()
field_collection_field_widget_embed_delay_required_validation in ./field_collection.module
FAPI #after_build of an individual field collection element to delay the validation of #required.

File

./field_collection.module, line 1718
Module implementing field collection field type.

Code

function _field_collection_collect_required_elements(&$element, &$required_elements) {

  // Recurse through all children.
  foreach (element_children($element) as $key) {
    if (isset($element[$key]) && $element[$key]) {
      _field_collection_collect_required_elements($element[$key], $required_elements);
    }
  }
  if (!empty($element['#required'])) {
    $element['#required'] = FALSE;
    $required_elements[] =& $element;
    $element += array(
      '#pre_render' => array(),
    );
    array_unshift($element['#pre_render'], 'field_collection_field_widget_render_required');
  }
}