You are here

public function BulkEditFormTrait::buildBundleForms in Views Bulk Edit 8.2

Builds the bundle forms.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

array $bundle_data: An array with all entity types and their bundles.

Return value

array The bundle forms.

2 calls to BulkEditFormTrait::buildBundleForms()
BulkEditForm::buildForm in src/Form/BulkEditForm.php
Form constructor.
ModifyEntityValues::buildConfigurationForm in src/Plugin/Action/ModifyEntityValues.php

File

src/Form/BulkEditFormTrait.php, line 65

Class

BulkEditFormTrait
Common methods for Views Bulk Edit forms.

Namespace

Drupal\views_bulk_edit\Form

Code

public function buildBundleForms(array $form, FormStateInterface $form_state, array $bundle_data) {

  // Store entity data.
  $form_state
    ->set('vbe_entity_bundles_data', $bundle_data);
  $form['#attributes']['class'] = [
    'views-bulk-edit-form',
  ];
  $form['#attached']['library'][] = 'views_bulk_edit/views_bulk_edit.edit_form';
  $bundle_count = 0;
  foreach ($bundle_data as $entity_type_id => $bundles) {
    foreach ($bundles as $bundle => $label) {
      $bundle_count++;
    }
  }
  foreach ($bundle_data as $entity_type_id => $bundles) {
    foreach ($bundles as $bundle => $label) {
      $form = $this
        ->getBundleForm($entity_type_id, $bundle, $label, $form, $form_state, $bundle_count);
    }
  }
  return $form;
}