You are here

public function BusinessRuleForm::targetEntityTypeCallback in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Form/BusinessRuleForm.php \Drupal\business_rules\Form\BusinessRuleForm::targetEntityTypeCallback()

Populates target_bundle options according to the selected entity type.

Parameters

array $form: The form array.

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

Return value

\Drupal\Core\Ajax\AjaxResponse The AjaxResponse.

File

src/Form/BusinessRuleForm.php, line 569

Class

BusinessRuleForm
Class BusinessRuleForm.

Namespace

Drupal\business_rules\Form

Code

public function targetEntityTypeCallback(array &$form, FormStateInterface $form_state) {
  $target_entity_type = $form_state
    ->getValue('target_entity_type');
  if (!empty($target_entity_type)) {
    $form['entity']['context']['target_bundle']['#options'] = $this->util
      ->getBundles($target_entity_type);
  }
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#target_bundle-wrapper', $form['entity']['context']['target_bundle']));
  return $response;
}