You are here

public function BricksTreeDynamicWidget::formElement in Bricks​ 8

Same name and namespace in other branches
  1. 2.x modules/bricks_dynamic/src/Plugin/Field/FieldWidget/BricksTreeDynamicWidget.php \Drupal\bricks_dynamic\Plugin\Field\FieldWidget\BricksTreeDynamicWidget::formElement()

File

modules/bricks_dynamic/src/Plugin/Field/FieldWidget/BricksTreeDynamicWidget.php, line 26

Class

BricksTreeDynamicWidget
Plugin annotation @FieldWidget( id = "bricks_tree_dynamic", label = @Translation("Bricks tree (Dynamic)"), description = @Translation("A tree of autocomplete text fields."), field_types = { "bricks_dynamic" } )

Namespace

Drupal\bricks_dynamic\Plugin\Field\FieldWidget

Code

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $element = parent::formElement($items, $delta, $element, $form, $form_state);

  // #default_value is en Entity or NULL.
  _bricks_form_element_alter($element, $items[$delta], $element['target_id']['#default_value']);
  hide($element['depth']);
  return $element;
}