• Resolved sneakyrock

    (@sneakyrock)


    Hi!

    I followed this tutorial “ACF Form: How to convert form to Bootstrap 4” but the Bootstrap row output is not working.

    I have copied all PHP code to the functions.php, JS to my custom.js and also i have applied “col-md-6” to the corresponding Wrapper Atrributes “class” fields.

    Deregistering the styles works. The part with “Bootstrap row, success message & submit button” is not working. “Wrap fields with form-group…” works. “Adding text-danger on required” and “Adding alert-danger on errors” is also not working.

    Wordpress 5.5
    Advanced Custom Fields PRO 5.8.14
    Advanced Custom Fields: Extended 0.8.7

    Thanks in advance for any help!

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello!

    Thanks for the feedback! Please be advised, this forum is a support platform for the ACF Extended plugin. The tutorial provided on the website let you customize the native ACF Form feature and your question is about general ACF development.

    I just tested the code, and it is working correctly:

    add_filter('acf/validate_form', 'acf_form_bootstrap_styles');
    function acf_form_bootstrap_styles($args){
        
        // Before ACF Form
        if(!$args['html_before_fields'])
            $args['html_before_fields'] = '<div class="row">'; // May be .form-row
        
        // After ACF Form
        if(!$args['html_after_fields'])
            $args['html_after_fields'] = '</div>';
        
        // Success Message
        if($args['html_updated_message'] == '<div id="message" class="updated"><p>%s</p></div>')
            $args['html_updated_message'] = '<div id="message" class="updated alert alert-success">%s</div>';
        
        // Submit button
        if($args['html_submit_button'] == '<input type="submit" class="acf-button button button-primary button-large" value="%s" />')
            $args['html_submit_button'] = '<input type="submit" class="acf-button button button-primary button-large btn btn-primary" value="%s" />';
        
        return $args;
        
    }
    

    ACF Form implementation:

    acf_form(array(
        'field_groups' => array('group_5f18a7cf4116d')
    ));
    

    Please make sure that you didn’t set any parameters in the acf_form() function for the html_before_fields & html_after_fields keys. As you can see, the acf/validate_form hook will override it, but check if those keys have been set beforehand, using if(!$args['html_before_fields']).

    This ACF Form implementation won’t work, if you define those keys:

    acf_form(array(
        'field_groups' => array('group_5f18a7cf4116d'),
        'html_before_fields' => '',
        'html_after_fields' => '',
    ));
    

    Please make sure your configuration is correct.

    Hope it helps.

    Regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Convert form to Bootstrap 4 not working’ is closed to new replies.