Problem/Motivation

prepopulate not working after $populate = \Drupal::service('prepopulate.populator'); implementation with clean drupal installation.

Proposed resolution

set value at correct location.

CommentFileSizeAuthor
#2 2996752-02.patch778 bytesvj

Comments

Vj created an issue. See original summary.

vj’s picture

Status: Active » Needs review
StatusFileSize
new778 bytes

Patch which worked for me.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Use the full render array path to the element. This includes things like delta, widget, etc.

kelvinwong’s picture

$form['widget'][0]['value']['#value'] is not always the structure for all field types. I have provided a patch in the ticket below, it should cover the field structure in most cases.

https://www.drupal.org/project/prepopulate/issues/3017136

heddn’s picture

https://cgit.drupalcode.org/prepopulate/tree/USAGE.md?h=8.x-2.x has some details on how to use this module. Perhaps it will assist with solving this issue here?

heddn’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)
heddn’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

All these concerns should be addressed in https://www.drupal.org/project/prepopulate/releases/8.x-2.1. Please read the usage docs and the tests in https://cgit.drupalcode.org/prepopulate/tree/tests/src/Functional/Prepop... for examples how to use this module.