The gform_mollie_components_object is a Gravity Forms filter that allows you to modify the Mollie Components object when displaying the Mollie Field.
Table of contents
Usage
To use the filter, add the following code in your functions.php file:
add_filter('gform_mollie_components_object', 'your_function_name', 10, 2);
Parameters
$args (array)– The Mollie components object.$form_id (int)– The current form ID.
More information
See Gravity Forms Docs: gform_mollie_components_object
Examples
Change placeholder text
To change the placeholder text of the Mollie Field, use the following code:
function change_mollie_placeholder_text($args, $form_id) {
// Modify the placeholder text
$args['placeholder'] = 'Your new placeholder text';
return $args;
}
add_filter('gform_mollie_components_object', 'change_mollie_placeholder_text', 10, 2);
Modify Mollie components style
To modify the style of the Mollie components, use the following code:
function modify_mollie_components_style($args, $form_id) {
// Modify the style
$args['style'] = array(
'base' => array(
'color' => '#303238',
'fontSize' => '16px',
'fontSmoothing' => 'antialiased'
)
);
return $args;
}
add_filter('gform_mollie_components_object', 'modify_mollie_components_style', 10, 2);
Enable/disable specific Mollie components
To enable or disable specific Mollie components, use the following code:
function enable_disable_mollie_components($args, $form_id) {
// Enable or disable specific components
$args['components'] = array('cardNumber', 'expiryDate', 'cvc');
return $args;
}
add_filter('gform_mollie_components_object', 'enable_disable_mollie_components', 10, 2);
Add custom data attributes
To add custom data attributes to the Mollie Field, use the following code:
function add_custom_data_attributes($args, $form_id) {
// Add custom data attributes
$args['data-custom-attribute'] = 'custom value';
return $args;
}
add_filter('gform_mollie_components_object', 'add_custom_data_attributes', 10, 2);
Modify Mollie components for specific forms
To modify Mollie components for specific forms, use the following code:
function modify_mollie_components_for_specific_forms($args, $form_id) {
// Check if the form ID matches the target form
if ($form_id == 123) {
// Modify the Mollie components for the specific form
$args['style'] = array(
'base' => array(
'color' => '#000000',
'fontSize' => '18px',
'fontSmoothing' => 'antialiased'
)
);
}
return $args;
}
add_filter('gform_mollie_components_object', 'modify_mollie_components_for_specific_forms', 10, 2);