You are here

public static function FieldCollectionEmbedWidget::delayRequiredValidation in Field collection 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php \Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget::delayRequiredValidation()

#after_build of a field collection element.

Delays the validation of #required.

File

src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php, line 135

Class

FieldCollectionEmbedWidget
Plugin implementation of the 'field_collection_embed' widget.

Namespace

Drupal\field_collection\Plugin\Field\FieldWidget

Code

public static function delayRequiredValidation($element, FormStateInterface $form_state) {

  // If the process_input flag is set, the form and its input is going to be
  // validated. Prevent #required (sub)fields from throwing errors while
  // their non-#required field collection item is empty.
  if ($form_state
    ->isProcessingInput()) {
    static::collectRequiredElements($element, $element['#field_collection_required_elements']);
  }
  return $element;
}