advancedforms / advanced-forms

WordPress plugin to create forms using Advanced Custom Fields
75 stars 14 forks source link

Too few arguments to function filter_submit_button_attributes() #42

Closed hacknug closed 6 years ago

hacknug commented 6 years ago

Using filter_submit_button_attributes() just as it is on the docs, gives the following error:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function filter_submit_button_attributes(), 3 passed in /app/public/wp-includes/class-wp-hook.php on line 286 and exactly 4 expected in /app/public/wp-content/themes/llos-isisi/includes/acf.php:72
Stack trace:
#0 /app/public/wp-includes/class-wp-hook.php(286): filter_submit_button_attributes(Array, Array, Array)
#1 /app/public/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array)
#2 /app/public/wp-content/plugins/advanced-forms/core/forms/forms-rendering.php(254): apply_filters('af/form/button_...', Array, Array, Array)
#3 /app/public/wp-includes/class-wp-hook.php(286): AF_Core_Forms_Rendering->render('form_5b6b0b3757...', Array)
#4 /app/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
#5 /app/public/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#6 /app/public/wp-content/plugins/advanced-forms/api/api-forms.php(16): do_action('af/form/render', 'form_5b6b0b3757...', Array)
#7 /app/public/wp-content/themes/llos-is in /app/public/wp-content/themes/llos-isisi/includes/acf.php on line 72
fabianlindfors commented 6 years ago

Hi!

Seems as if the documentation is incorrect, I'll fix it as soon as possible. This is the way it should be:

<?php

function filter_submit_button_attributes( $attributes, $form, $args ) {
    $attributes['class'] .= ' button';

    return $attributes;
}
add_filter( 'af/form/button_attributes', 'filter_submit_button_attributes', 10, 3 );
add_filter( 'af/form/button_attributes/id=FORM_ID', 'filter_submit_button_attributes', 10, 3 );
add_filter( 'af/form/button_attributes/key=FORM_KEY', 'filter_submit_button_attributes', 10, 3 );

Thank you for pointing this out to me! :)