Skip to content
Snippets Groups Projects
Unverified Commit d57a746a authored by Michael Lee's avatar Michael Lee Committed by GitHub
Browse files

Merge pull request #429 from ASCWebServices/canini-2

adding google map autofill to content type
parents b5a21cbc 901cfc01
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ function google_map_autofill_form_alter(&$form, &$form_state, $form_id) {
if(in_array($form_id,['user-register-form','user_register_form'])) {
$form['field_google_map']['#disabled'] = 'disabled';
}
if(in_array($form_id,['node_departments_centers_form','node_departments_centers_edit_form'])) {
$form['field_dc_google_map']['#disabled'] = 'disabled';
}
}
function google_map_autofill_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
......@@ -16,4 +19,11 @@ function google_map_autofill_entity_presave(Drupal\Core\Entity\EntityInterface $
$entity->field_google_map->value = $address;
//save is done automatically
}
if($entity->bundle() == "departments_centers"){
//get content from field_address and check it for linebreaks; if linebreaks exist replace them with single space
$address = trim(preg_replace('/\s+/', ' ', $entity->field_dc_address->value));
//set field_google_map value to equal field_address
$entity->field_dc_google_map->value = $address;
//save is done automatically
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment