2017-10-11 3 views
0
내가 여기에 구글의 지오 코더를 사용하고

:드루팔 후크 변경 넣은 사람은 아니다 일

(function ($) { 
Drupal.behaviors.ems_offices = { 
    attach: function (context, settings) { 
     geocoder = new google.maps.Geocoder(); 
     $("#edit-submit").click(function(e){ 
      var googleMapAdress  = $("#edit-field-offices-google-maps-info-und-0-value").val(); 
      var googleMapsHiddenInput = $("input[name='google_maps_geolocation']"); 
      e.preventDefault(); 

      geocoder.geocode({ 'address': googleMapAdress}, function(results, status) { 
       if (status == google.maps.GeocoderStatus.OK) { 
        if (googleMapAdress === '') { 
         googleMapsHiddenInput.val(''); 
        } else { 
         googleMapsHiddenInput.val(JSON.stringify(results)); 
        } 
       } 
      }); 

      $("#offices-node-form").submit(); 
     }); 
    } 
    }; 
}(jQuery)); 

을 너무 시도 후 *의 .module

function ems_offices_form_offices_node_form_alter(&$form, &$form_state, $form_id) { 
if ('offices_node_form' == $form_id) { 
    $form['#attached']['js'][] = drupal_get_path("module", "ems_offices")."/assets/js/change_address_to_google_map_object.js" ; 
    $form['#submit'][] = 'ems_offices_submit'; 
    $form['google_maps_geolocation'] = array(
     '#type'   => 'hidden', 
     '#default_value' => '', 
    ); 
} 

}

function ems_offices_submit(&$form, &$form_state) { 
    if ($_POST['google_maps_geolocation'] !== '') { 
    $googleMapsInformation              = $_POST['google_maps_geolocation']; 
    $form_state['values']['field_offices_google_maps_info']['und'][0]['value'] = $googleMapsInformation; 
    } 
} 

에서 그들을 후크 디버깅 나는 js 스크립트가 작동 중이고 json 응답이 있음을 알았습니다. 그러나 모듈은이 값을받지 못합니다. 이 빌드가 내 도메인에서 작동하지만 현지에서는 작동하지 않는 흥미로운 부분입니다. 어디에서 문제가 될 수 있습니까?

+0

"하지만 모듈에서이 값을받지 못합니다."... 제출 기능이 작동하지만 $ _POST [ 'google_maps_geolocation']이 빈 문자열이라는 것을 의미합니까? 제출 된 값을 $ _POST [ 'google_maps_geolocation'] 대신 $ form_state에서 확인 하시겠습니까? – 2pha

답변