Gravity Form gform_pre_submission 挂钩是否适用于带有“下一步”按钮和多个步骤的表单?

Does Gravity Form gform_pre_submission hook work on forms with Next button and multiple steps?

我的表单有多个步骤。

您填写一些内容,单击下一步,然后填写更多内容。

我担心的是该函数直到按下提交按钮的最后一刻才会触发。

到那时我可以操作以前字段的数据吗?

<?php


//Change _6 to the form ID number everywhere
add_action('gform_pre_submission_6', 'capitalize_fields_6');

function capitalize_fields_6($form){

        // add all the field IDs you want to capitalize, to this array

        $fields_to_cap = array('input_id_here');

        // add all uppercase first letter id's, to this array

        $field_to_firstLetter = array('input_id_here');


        foreach ($fields_to_cap as $each) {

                // for each field, convert the submitted value to uppercase and assign back to the POST variable
                // the rgpost function strips slashes

                $_POST[$each] = strtoupper(rgpost($each));
        }

        foreach ($field_to_firstLetter as $each) {

                $_POST[$each] = ucwords(rgpost($each));
        }



        // return the form, even though we did not modify it
        return $form;
}


?>

gform_pre_submission 挂钩仅在表单实际发布后,但在对其中的数据进行任何重要操作之前触发。

多页表单不会在页面之间提交任何内容,它或多或少只是将页面包装成块并 shows/hides 基于它们 - 它只是设计为一种 "more aesthetic" 呈现方式一个长表单,而不是在你的页面上有一个非常可滚动的表单。例外情况是 Save & Continue 选项,但字段 masks/formats 之外的任何内容都没有得到实际验证,它不是 运行 到 gform_pre_submission

如果您需要在前面的页面上 "manipulate the data",您最好在所需的输入上使用 JavaScript 的 .onchange() event handler function to preemptively change the data before it's submitted, but after it's been typed into the fields. You could also use CSS's text-transform 属性 并将其设置为 capitalize(注意这只会影响 display 而不会影响 actual 值,所以你仍然需要 运行 它通过 gform_pre_submission 挂钩。