Home › Forums › Front-end Issues › Front form doesn't save my fields
Hello,
i’m trying to add some acf fields into an existing plugin form.
Fields are displayed correctly, the values added in the backend are updated and displayed in front, but when I try to create or update these values in front-end, nothing happens.
I added the code acf_form_head (); at the top of my page, at the very top before get_header ();
<?php
acf_register_form(array(
'id' => 'mytest',
'post_id' => $id,
'form' => false,
'post_title' => false,
'post_content' => false,
'uploader' => 'basic',
'field_groups' => array(2135),
));
acf_form('mytest');
?>
Everything seems ok, but it does not register when I submit my form …
If anyone have an idea of my problem, thanks for the help OR if it’s possible to update ACF fields by another method that might solve my worries.
Form process:
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
acf_form_head();
get_header();
$car_edit = false;
if (!empty($_GET['edit_car']) and $_GET['edit_car']) {
$car_edit = true;
}
$restricted = false;
if (is_user_logged_in()) {
$user = wp_get_current_user();
$user_id = $user->ID;
$restrictions = st_get_post_limits($user_id);
} else {
$restrictions = st_get_post_limits('');
}
if ($restrictions['posts'] < 1) {
$restricted = true;
}
$vars = array();
if ($car_edit):
if (!empty($_GET['item_id'])) {
$item_id = intval($_GET['item_id']);
$vars = array(
'id' => $item_id
);}
endif;
?>
<div>
<form method="POST" action="" enctype="multipart/form-data" id="car_form">
<?php if ($car_edit): ?>
<input type="hidden" value="<?php echo intval($item_id); ?>" name="current_car_id"/>
<?php endif; ?>
<?php load_template('add_car/stp1', $vars); ?>
...
<button type="submit" class="enabled" data-load="edit" >Save</button
</form>
</div>
<?php
get_footer();
acf_form()
needs to be called somewhere inside the <form ...></form>
Thanks for your reply John.
acf_form() is called inside my form, but it still not register my field …
I don’t see where acf_form() is called inside the form tags, what am I missing?
This part:
<?php
acf_register_form(array(
'id' => 'mytest',
'post_id' => $id,
'form' => false,
'post_title' => false,
'post_content' => false,
'uploader' => 'basic',
'field_groups' => array(2135),
));
acf_form('mytest');
?>
is called inside this part
<form method="POST" action="" enctype="multipart/form-data" id="stm_sell_a_car_form">
<?php if ($car_edit){ ?>
<input type="hidden" value="<?php echo intval($vars['id']); ?>" name="stm_current_car_id"/>
<input type="hidden" value="update" name="stm_edit"/>
<?php } else { ?>
<input type="hidden" value="adding" name="stm_edit"/>
<?php } ?>
<?php do_action('stm_vin_auto_complete_require_template'); ?>
<?php stm_listings_load_template('add_car/title', $vars); ?>
<?php stm_listings_load_template('add_car/step_1', $vars); ?>
<?php stm_listings_load_template('add_car/step_2', $vars); ?>
<?php stm_listings_load_template('add_car/step_3', $vars); ?>
<?php stm_listings_load_template('add_car/step_4', $vars); ?>
<?php stm_listings_load_template('add_car/step_5', $vars); ?>
<?php stm_listings_load_template('add_car/step_6', $vars); ?>
</form>
The topic ‘Front form doesn't save my fields’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.