You are here

public function ItemForm::buildForm in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Form/ItemForm.php \Drupal\business_rules\Form\ItemForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/ItemForm.php, line 386

Class

ItemForm
Base class for Business rules item.

Namespace

Drupal\business_rules\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $itemManager = $this
    ->getItemManager();
  $form['actions']['#weight'] = 1200;
  $type = $this->entity
    ->getType() ? $this->entity
    ->getType() : $form_state
    ->getValue('type');
  if (!empty($type)) {
    $definition = $itemManager
      ->getDefinition($type);
    $reflection = new \ReflectionClass($definition['class']);
    $custom_item = $reflection
      ->newInstance($definition, $definition['id'], $definition);
    $custom_item
      ->buildForm($form, $form_state);
  }
  return $form;
}