gform_submit_button

gform_submit_button

DescriptionUsageParametersExamples1. Change input to button2. Add text after the button3. Remove the button4. Append a JavaScript action to the button5. Append custom CSS classes to the buttonPlacementSource Code

Description
This filter is executed when the form is displayed and can be used to completely change the form button tag (i.e. ).
Usage
The following would apply your function to all forms.
add_filter( 'gform_submit_button', 'your_function_name', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_submit_button_FORMID)
add_filter( 'gform_submit_button_5', 'your_function_name', 10, 2 );

Parameters

$button_input string
The string containing the tag to be filtered.

$form Form Object
The form currently being processed.

Examples
1. Change input to button
This example changes the default input type to use the button element with an included span, popular for implementing the Sliding Door CSS technique.
add_filter( 'gform_submit_button', 'form_submit_button', 10, 2 );
function form_submit_button( $button, $form ) {
return "";
}

Note: The above is just a quick example showing how to use the filter. Using the above code will prevent the form submitting as the onclick attribute is missing.
Here』s another example which would change all the next, previous, and submit buttons so they use button elements from a single function while maintaining attributes such as onclick from original inputs.
/**
* Filters the next, previous and submit buttons.
* Replaces the forms buttons with

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注