The gaddon_no_output_field_properties is a filter in Gravity Forms that controls the HTML properties that are outputted for a field. It can be used to either allow or deny specific properties to be added to the field HTML.
Usage
To use this filter, you need to add it to your functions.php
file with a specific function name you want to be called. Like so:
add_filter( 'gaddon_no_output_field_properties', 'your_function_name' );
Inside your_function_name
, you can add your custom code to modify the properties.
Parameters
- $properties (array): An array containing the properties that are not allowed to be outputted.
- $field (Form Object): The current field meta that is being parsed.
More Information
See Gravity Forms Docs: gaddon_no_output_field_properties
This filter is a part of the Gravity Forms add-on framework and can be found in class-gf-addon.php
. It’s not deprecated, and there are no plans for it to be as of the current version.
Examples
Allowing a Custom Property
function your_function_name( $properties, $field ) { $properties[] = 'your_custom_property'; // Adding your custom property to the array return $properties; // Return the updated properties } add_filter( 'gaddon_no_output_field_properties', 'your_function_name', 10, 2 );
In this example, we’re adding a custom property to the array of allowed properties. The function takes the current properties and field as arguments, adds our custom property to the array, and then returns the updated array.
Denying a Custom Property
function your_function_name( $properties, $field ) { if(($key = array_search('your_custom_property', $properties)) !== false) { unset($properties[$key]); // Remove your custom property from the array } return $properties; // Return the updated properties } add_filter( 'gaddon_no_output_field_properties', 'your_function_name', 10, 2 );
In this example, we’re checking if our custom property is in the array of properties. If it is, we remove it and then return the updated array. This effectively denies our custom property.
Allowing Multiple Custom Properties
function your_function_name( $properties, $field ) { $custom_properties = ['custom_property_1', 'custom_property_2', 'custom_property_3']; // Your custom properties $properties = array_merge($properties, $custom_properties); // Merge your custom properties with the current properties return $properties; // Return the updated properties } add_filter( 'gaddon_no_output_field_properties', 'your_function_name', 10, 2 );
This example shows how you can add multiple custom properties at once. We define an array of custom properties and then merge this with the current properties.
Allowing Custom Property for Specific Field
function your_function_name( $properties, $field ) { if ( $field->id == 'your_field_id' ) { // Check if the current field is your specific field $properties[] = 'your_custom_property'; // Add your custom property } return $properties; // Return the updated properties } add_filter( 'gaddon_no_output_field_properties', 'your_function_name', 10, 2 );
In this example, we’re adding a custom property but only for a specific field. We check if the current field is the one we want, and if it is, we add our custom property to the array of properties.
Denying All Properties
function your_function_name( $properties, $field ) { $properties = []; // Set properties to an empty array return $properties; // Return the updated properties } add_filter( 'gaddon_no_output_field_properties', 'your_function_name', 10, 2 );
In this final example, we’re denying all properties by setting the properties array to be empty. This would mean that no properties are outputted for the field. Use this with caution, as it may affect the functionality of your form.
These examples should give you a good understanding of how to use the gaddon_no_output_field_properties filter. Remember to replace ‘your_function_name’, ‘your_custom_property’, and ‘your_field_id’ with your own specific function names, properties, and field IDs.