function og_prepopulate_after_build in Prepopulate 8.2
An #after_build function to set the values prepopulated in the request.
1 string reference to 'og_prepopulate_after_build'
- og_prepopulate_field_widget_og_complex_form_alter in modules/
og_prepopulate/ og_prepopulate.module - Implements hook_field_widget_WIDGET_TYPE_form_alter() for og_complex.
File
- modules/
og_prepopulate/ og_prepopulate.module, line 33 - The module file for og_prepopulate.
Code
function og_prepopulate_after_build($element) {
$field_name = reset($element['#parents']);
$entity_id = \Drupal::request()->query
->get($field_name);
/** @var \Drupal\prepopulate\Populate $populate */
$populate = \Drupal::service('og_prepopulate.populator');
// This lets us use URLs like example.com/node/add/page?og_audience=1.
$populate
->populateForm($element, [
'target_id' => $entity_id,
]);
return $element;
}