Support

Account

Home Forums Front-end Issues acf_form_head(); do not call scripts and style from ACF

Helping

acf_form_head(); do not call scripts and style from ACF

  • Hello Elliot.

    I followed the instructions of this link: http://www.advancedcustomfields.com/resources/functions/acf_form/
    to create front-end form on my website.

    Everything seems to be working perfectly, but I can not make those elements such as repeater and date_picker work as well, because the tag acf_form_head(); seems that is not working perfectly.

    What should I do?

    Here are my codes

    page.php

    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    
        <?php if (have_posts()) : the_post(); ?>
            <div id="primary" class="container_12">
              <div id="content" role="main" class="grid_12">
    
                <h1>Formulário</h1>
           
                <?php 
           
                $args = array(
                  'post_id' => 'new',
                  'field_groups' => array( 6 )
                );
           
                acf_form(array(
                'post_title'        => false,
                'updated_message'   => 'Enviado',
                'submit_value'      => 'Enviar'
                ));
           
                ?>
            
              </div><!-- #content -->
            </div><!-- #primary -->
        <?php endif; ?>
     
    <?php get_footer(); ?>
    

    function.php

    function my_pre_save_post( $post_id )
    {
        // check if this is to be a new post
        if( $post_id != 'new' )
        {
            return $post_id;
        }
     
        // Create a new post
        $post = array(
            'post_status'  => 'draft' ,
            'post_title'  => 'A title, maybe a $_POST variable' ,
            'post_type'  => 'post' ,
        );  
     
        // insert the post
        $post_id = wp_insert_post( $post ); 
     
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
     
        // return the new ID
        return $post_id;
    }
     
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    
  • Update.

    I’ve receiving the following error
    Uncaught ReferenceError: acf is not defined

    on this piece of code

    <script type="text/javascript">
    acf.o.post_id = 14;
    </script>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘acf_form_head(); do not call scripts and style from ACF’ is closed to new replies.