Skip to content

Instantly share code, notes, and snippets.

@suresh-kumara-gist
Last active September 8, 2017 10:47
Show Gist options
  • Save suresh-kumara-gist/155547434c4e0e9df81a210639f350b0 to your computer and use it in GitHub Desktop.
Save suresh-kumara-gist/155547434c4e0e9df81a210639f350b0 to your computer and use it in GitHub Desktop.
drupal 8 paragraph field widget alter
function attendance_management_field_widget_form_alter(&$element, &$form_state, &$context) {
if ($element['#title'] == "class label" && $element['#field_parents']['0'] == 'field_sessions_classes') {
$delta = $element['#delta'];
$attendance = \Drupal::routeMatch()->getParameter('attendance');
$classlabel = $attendance->field_sessions_classes->referencedEntities()[$delta]->field_class_label->getValue()['0']['markup'];
$element['markup']['#text'] = $classlabel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment