You are here

function _paragraphs_collect_required_elements in Paragraphs 7

Collects all embedded required fields.

Parameters

array $element: A form element array containing basic properties of the paragraphs element.

array|null $required_elements: An array containing required paragraphs elements.

1 call to _paragraphs_collect_required_elements()
paragraphs_field_widget_embed_delay_required_validation in ./paragraphs.field_widget.inc
After-build callback to validate an individual paragraphs element.

File

./paragraphs.field_widget.inc, line 713
Holds functions for the paragraphs widgets.

Code

function _paragraphs_collect_required_elements(array &$element, &$required_elements = array()) {

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