Purpose

Filter and modify the settings of specific form fields programmatically. This filter allows you to dynamically adjust field settings for forms where the filter_form_field_settings option is enabled in the Form Field Option.

Usage

add_action( 'wr_form_field_settings', array( $this, 'my_form_field_setting' ), 10, 2 );

Parameters

  • $settings (array): The settings of the current Form Field, including configuration details such as the identifier and options.
  • $form (Form): The form object containing the field for which the settings are being filtered.

Use Case

This functionality is useful when:

  • You need to dynamically update field settings based on specific conditions, such as user roles, form identifiers, or external inputs.
  • Adding or modifying configuration options for certain fields is required.

Implementation Example

The following example modifies the settings of a field identified by “identifier”:

add_action( 'wr_form_field_settings', array( $this, 'my_form_field_setting' ), 10, 2 );
 
public function my_form_field_setting( array $settings, Form $form ): array {
    if ( isset( $settings["identifier"] ) && $settings["identifier"] === "form_field_identifier" ) {
        $settings["placeholder"] = "Enter your value here";
        $settings["required"] = true;
    }
    return $settings; 
}

Attention: The $settings variable contains the configuration settings for the form field.