2017-09-18 5 views
0

Wordpress 양식에 레이블 목록을 전달하여 확인란, 가급적 중력 양식을 작성해야합니다. "동적으로 채워지는 필드 허용"은 값을 채우고 체크 박스 목록을 비동기 적으로 만들지는 않습니다. 예 : yahoo.com/?CheckboxLabels=yellow & 녹색 & 빨간색Gravity Forms에서 값이 아닌 라벨을 전달하는 방법 Checkbox URL 검색어 매개 변수

체크 박스 :

  1. 노란색
  2. 녹색
  3. 빨간색

이 작업을 수행 할 수있는 방법이 있나요? 고맙습니다.

답변

0

이 테마의 functions.php에 추가하여 나를 위해 일하게 종료를 확인합니다.

<?php 
//NOTE: update the ' 1' to the ID of your form 
add_filter('gform_pre_render_1', 'populate_checkbox'); 
add_filter('gform_pre_validation_1', 'populate_checkbox'); 
add_filter('gform_pre_submission_filter_1', 'populate_checkbox'); 
add_filter('gform_admin_pre_render_1', 'populate_checkbox'); 



function populate_checkbox($form) { 

    foreach($form['fields'] as &$field) { 

     //NOTE: replace 3 with your checkbox field id 
     $field_id = 6; 
     if ($field->id != $field_id) { 
      continue; 
     } 

     $input_id = 1; 


     foreach (explode(',', $_GET["addresses"]) as $name => $value) { 

      //skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs) 
      if ($input_id % 10 == 0) { 
       $input_id++; 
      } 

      $choices[] = array('text' => $value, 'value' => $value); 
      $inputs[] = array('label' => $value, 'id' => "{$field_id}.{$input_id}"); 

      $input_id++; 
     } 

     $field->choices = $choices; 
     $field->inputs = $inputs; 

    } 

    return $form; 
} 

?>