
Here is the code for my front end form:
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(array(
'post_id' => 'new',
'field_groups' => array( 66 ),
'submit_value' => 'Publish Your Cure!',
'id' => 'byc'
)); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
I am actually having a few issues. I am mentioning them all because they could possibly be related.
1) My form submits even when the required fields are not filled in.
2) image upload functionality does not work. I press the button and nothing happens. No console errors either.
3) I get the following console error when I submit the form:
Uncaught ReferenceError: acf is not defined ?page_id=67&updated=true&post_id=81:196
I checked that up. It comes from line 1244 of api.php in this line:
acf.o.post_id = <?php echo is_numeric($options[‘post_id’]) ? $options[‘post_id’] : ‘”‘ . $options[‘post_id’] . ‘”‘; ?>;
Apparently, acf object is not recognized.
All help is appreciated, thanks.
From where you created the custom field groups by code or from the back-end.
1. back-end : –
you can see the option to add the required field
2. through code : –
Here is an example which i created
`array (
‘key’ => ‘field_53ba5630e48e8’,
‘label’ => ‘Email’,
‘name’ => ’email’,
‘type’ => ’email’,
‘instructions’ => ‘Please enter your email’,
<strong>’required’ => 1,</strong>
‘default_value’ => ”,
‘placeholder’ => ”,
‘prepend’ => ”,
‘append’ => ”,
)
You can see the required field value.