You are here

public static function ScheduledPublishWidget::getElement in Scheduled Publish 8.3

Returns a SP widget nearest to the triggering element.

File

src/Plugin/Field/FieldWidget/ScheduledPublishWidget.php, line 362

Class

ScheduledPublishWidget
Plugin implementation of the 'scheduled_publish_widget' widget.

Namespace

Drupal\scheduled_publish\Plugin\Field\FieldWidget

Code

public static function getElement($form, FormStateInterface $form_state) {
  $element = [];
  $triggering_element = $form_state
    ->getTriggeringElement();

  // Remove the action.
  $array_parents = array_slice($triggering_element['#array_parents'], 0, -1);
  while (!isset($element['#sp_root'])) {
    $element = NestedArray::getValue($form, $array_parents);
    array_pop($array_parents);
  }
  return $element;
}