You are here

public static function SubformState::createWithParents in Typed Data API enhancements 8

Creates a new subform by specifying the array parents.

Parameters

string[] $arrayParents: The array parents; i.e., where the sub-form is located in the parent. For example if a sub-form is located in $form['fieldset']['parent'], the array parents would be "fieldset" and "parent".

mixed[] $parentForm: The subform's complete parent form array.

\Drupal\Core\Form\FormStateInterface $parentFormState: The parent form state.

Return value

static

3 calls to SubformState::createWithParents()
FormWidgetExampleForm::buildForm in tests/modules/typed_data_widget_test/src/FormWidgetExampleForm.php
Form constructor.
FormWidgetExampleForm::submitForm in tests/modules/typed_data_widget_test/src/FormWidgetExampleForm.php
Form submission handler.
FormWidgetExampleForm::validateForm in tests/modules/typed_data_widget_test/src/FormWidgetExampleForm.php
Form validation handler.

File

src/Form/SubformState.php, line 35

Class

SubformState
Class SubformState.

Namespace

Drupal\typed_data\Form

Code

public static function createWithParents(array $arrayParents, array &$parentForm, FormStateInterface $parentFormState) {
  $exists = NULL;
  $form =& NestedArray::getValue($parentForm, $arrayParents, $exists);
  if (!$exists) {
    $form = static::getNewSubForm();
  }
  $instance = parent::createForSubform($form, $parentForm, $parentFormState);
  $instance->arrayParents = $arrayParents;
  return $instance;
}