public function LayoutParagraphsWidget::validateBehaviors in Layout Paragraphs 1.0.x
Validate paragraph behavior form plugins.
Parameters
array $element: The element to validate.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
array $form: The complete form array.
File
- src/
Plugin/ Field/ FieldWidget/ LayoutParagraphsWidget.php, line 1438
Class
- LayoutParagraphsWidget
- Entity Reference with Layout field widget.
Namespace
Drupal\layout_paragraphs\Plugin\Field\FieldWidgetCode
public function validateBehaviors(array $element, FormStateInterface $form_state, array $form) {
/** @var \Drupal\paragraphs\ParagraphInterface $entity */
$entity = $element['#entity'];
// Validate all enabled behavior plugins.
$paragraphs_type = $entity
->getParagraphType();
if ($this->currentUser
->hasPermission('edit behavior plugin settings')) {
foreach ($paragraphs_type
->getEnabledBehaviorPlugins() as $plugin_id => $plugin_values) {
if (!empty($element[$plugin_id])) {
$subform_state = SubformState::createForSubform($element[$plugin_id], $form_state
->getCompleteForm(), $form_state);
$plugin_values
->validateBehaviorForm($entity, $element[$plugin_id], $subform_state);
}
}
}
}