【问题标题】:Dynamically Populate Custom Field (Gravity Forms)动态填充自定义字段(重力形式)
【发布时间】:2012-02-03 23:34:21
【问题描述】:

我有一个表格可以计算一个人选择了多少次值。每个问题有 3 个答案,其值为“self”、“others”或“social”。哪个具有 MOST 将作为结果返回。

最终,我需要一个对用户隐藏的自定义帖子字段,并填充此结果。目前它在表单提交后显示:

return $confirmation

我的functions.php 文件底部粘贴了http://pastie.org/3312298

在表单作为条目提交给我们之前,我不太确定如何将结果放入框中。

www.webdesignsalemoregon.com/surveytest

是它现在所在的地方

【问题讨论】:

    标签: php wordpress query-string


    【解决方案1】:

    你正在采取一种复杂的方式来做到这一点。

    为“self”<input name='self'> 指定每个单选按钮,其余的也一样

    $self_answers = count($_POST['self']);
    $others_answers = count($_POST['others']);
    $social_answers = count($_POST['social']);
    
    $max = max($self_answers, $others_answers, $social_answers) ; 
    
    if($max == $self_answers) {
        $greatest = "self";
    } else if($max == $others_answers) {
        $greatest = "others";
    } else {
        $greatest = "social";
    }
    

    【讨论】:

    • 我在其中的代码是由 Gravity Forms 开发人员提供给我的,它可以正常工作(无论是否复杂)。我只需要在表单提交给我们之前获取计算值以预填充自定义字段
    猜你喜欢
    • 1970-01-01
    • 2021-06-05
    • 2016-02-19
    • 2014-11-16
    • 2019-11-01
    • 2017-12-23
    • 2020-07-22
    • 2014-01-29
    • 2015-05-03
    相关资源
    最近更新 更多