You are here

public static function EntitySubqueueForm::processMachineNameSource in Entityqueue 8

Form API callback: Sets the 'source' property of a machine_name element.

This method is assigned as a #process callback in formElement() method.

File

src/Form/EntitySubqueueForm.php, line 114

Class

EntitySubqueueForm
Form controller for the entity subqueue edit forms.

Namespace

Drupal\entityqueue\Form

Code

public static function processMachineNameSource($element, FormStateInterface $form_state, $form) {
  $source_field_state = WidgetBase::getWidgetState($form['#parents'], $element['#source_field'], $form_state);

  // Hide the field widget if the source field is not configured properly or
  // if it doesn't exist in the form.
  if (empty($element['#source_field']) || empty($source_field_state['array_parents'])) {
    $element['#access'] = FALSE;
  }
  else {
    $source_field_element = NestedArray::getValue($form_state
      ->getCompleteForm(), $source_field_state['array_parents']);
    $element['#machine_name']['source'] = $source_field_element[0]['value']['#array_parents'];
  }
  return $element;
}