Support requests in Drupal Core are not well attended. Did you figure this out?
- Status changed to Closed: outdated
6 months ago 6:43pm 28 July 2024
I would like to populate link field from entity reference to another link field in my content edit.
Create a content, add entity reference field from another content with link link field referenced by view.
Create module for ajax populate link field.
Here is my module code :
function _injector_autofill_fields($form, $form_state) {
$eid = $form_state->getValue('field_entreprises_marque')[0]['target_id'];
$event = Node::load($eid);
$entreprise = $event->title->value;
$phone = $event->field_telephone->value;
$email = $event->field_courriel->value;
$adresse = $event->field_adresse->value;
$code = $event->field_code_postal->value;
$ville = $event->field_ville->value;
$web = $event->field_site_web->value;
$response = new AjaxResponse();
$response->addCommand(new InvokeCommand('#edit-field-telephone-0-value', 'val', [$phone]));
$response->addCommand(new InvokeCommand('#edit-field-courriel-0-value', 'val', [$email]));
$response->addCommand(new InvokeCommand('#edit-field-adresse-0-value', 'val', [$adresse]));
$response->addCommand(new InvokeCommand('#edit-field-code-postal-0-value', 'val', [$code]));
$response->addCommand(new InvokeCommand('#edit-field-ville-0-value', 'val', [$ville]));
$response->addCommand(new InvokeCommand('#edit-field-nom-de-l-entreprise-0-value', 'val', [$entreprise]));
$response->addCommand(new InvokeCommand('#edit-field-site-web-0-value', 'val', [$web]));
return $response;
}
I know that i can't do like this but, how to do it for :
$web = $event->field_site_web->value;
AND
$response->addCommand(new InvokeCommand('#edit-field-site-web-0-value', 'val', [$web]));
Thanks in advance!
Closed: outdated
11.0 π₯
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Support requests in Drupal Core are not well attended. Did you figure this out?