2016-10-13 109 views
0

我有一個複雜的Gravity Form內置,它有10頁。我使用字段來構建一個「字符串」,然後根據用戶在表單中的選擇,匹配CPT名稱以獲取元數據以顯示選擇內容。重力形式多頁丟失POST值

我有一個字段沒有在POST中保留它的值。當我選擇頁面上的值時,我可以看到它,然後當我點擊下一頁時,值仍然存在。但是,在兩頁之後,值(和字段)從POST消失。

這是我放在一起的函數,它構建了我的產品字符串。

add_filter('gform_pre_render_12', 'display_choice_result'); 

function display_choice_result($form) { 
$current_page = GFFormDisplay::get_current_page($form['id']); 
$html_content = ""; 
$prod_string = ""; 

if ($current_page >= 10) { 
    foreach ($form['fields'] as &$field) { 
     // Check for a class of "product-builder-item" on the field 
     // I use this as another way to denote what fields to add to string 
     if (strpos($field->cssClass, 'product-builder-item') === false) { 
      continue; 
     } 

     //gather form data to save into html field (Field ID 14 on Form ID 12) 
     //exclude page break and any hidden fields 
     if ($field->id != 14 && $field->type != 'page') { 
      $is_hidden = RGFormsModel::is_field_hidden($form, $field, array()); 
      $populated = rgpost('input_' . $field->id); 

      // Make sure the field we are getting the value from is not hidden and has a value 
      if (!$is_hidden && $populated !='') { 
       $html_content .= '<li>' . $field->label . ': ' . rgpost('input_' . $field->id) . '</li>'; 
       $prod_string .= rgpost('input_' . $field->id); 
      } 
     } 
    } 
    // Do a bunch of stuff here with the $prod_string variable 
    // ... 
    // ... 
    // ... 
} 
return $form; 
} 

截圖顯示相關的帖子disappearing..The POST場input_22

值這是一個網頁後,我從外地

enter image description here

選擇

這是兩個後的頁面,

enter image description here

以前任何人遇到過這種情況,或者有任何想法,爲什麼它會消失?

謝謝。

+0

你能解決這個問題嗎?遇到類似的情況。 – kisabelle

回答

0

我的問題與您所描述的完全相同。我意識到一個jQuery函數干擾了Gravity Form過程。 jQuery功能被設置爲將郵政編碼字段從文本類型更改爲電話號碼,以便在移動設備上打開數字鍵盤。這是導致我的問題。

+1

歡迎來到Stack Overflow。你是否也可以發佈你的代碼(之前和之後),這將有助於確定你的答案是否與問題相關。 (你可以編輯你的答案) – Mikkel