I tried to update field with form in Repeater field
This is my code for update field in single.php
if(isset($_POST['submit'])){
if( have_rows('custom_req') ){
while( have_rows('custom_req') ){ the_row();
$r_req = get_sub_field('req_fie');
if ($_POST['radio-b'] == $r_req ) {
update_sub_field('rq_answer', 'new_value');
}
}
}
}
if( have_rows('custom_req') ){
while( have_rows('custom_req') ){ the_row();
the_sub_field('rq_answer'); // This line shows the previous value
}
}
the sub field after click updated but,
the problem is shows the previous value, and the page must be reloaded to show the new value
Why is that? How do I solve this problem?
Thanks for any help
Are you actually trying to get the values immediately after updating?
Is this in your template file? If it is your first if
if(isset($_POST['submit'])){
should never run since this value should not be set when the template file is loading.
Thanks for answer,
in fact i solved this problem
now my question is , Is this method safe?
i want user can update field when click submit