【问题标题】:Gravity Forms Pre Populate Dropdown working but only after I click Update FormGravity Forms Pre Populate Dropdown 工作但仅在我单击更新表单后
【发布时间】:2014-01-19 23:39:46
【问题描述】:

使用下面的示例,我可以成功地在 Gravityforms 编辑器中使用存储在我的数据库表中的状态列表填充下拉列表...

add_filter("gform_pre_render_3", populate_dropdown1); //5 is the GF Form ID
add_filter("gform_admin_pre_render_3", populate_dropdown1);

function populate_dropdown1($form){
global $wpdb; //Accessing WP Database (non-WP Table) use code below.
$results = $wpdb->get_results("SELECT btc_state_short from btc_state_list");

$choices = array();
$choices[] = array("text" => "Select a State", "value" => ""); //adding a array option with no value, this will make the user select and option.

foreach ($results as $result) {
$choices[] = array("text" => $result->btc_state_short, "value" => $result->btc_state_short);
}

foreach($form["fields"] as &$field){
if($field["id"] == 1){
$field["choices"] = $choices;
}
}

return $form;
}

这很好用,但只有在您单击“更新表单”后。当您最初创建下拉列表时,它具有标准字段...

First Choice
Second Choice
Third Choice

有没有办法在拖入后立即预填充它?

【问题讨论】:

    标签: wordpress gravity-forms-plugin


    【解决方案1】:

    在 Gravity Forms 中,该问题已在最新版本的表单字段中得到解决。一旦您选择 DropDown 并在您的字段上生成它,现在就会有一个完整的通用下拉列表。在 Common 生成的字段(即 First Choice Second Choice Third Choice)下方有一个标题为“批量添加/预定义选择”的按钮......

    只需单击该按钮并选择您希望自动填充的字段,它就会被填充。

    希望对您有所帮助。

    EP System Technologies 技术

    使用 GravityForms 版本 1.8.17 |由火箭天才 |

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 2018-11-30
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2021-09-03
      • 2015-02-10
      • 2014-11-27
      • 2015-03-29
      相关资源
      最近更新 更多