Hi everybody,
I try to add multiple row calculate by a start date and a end date this work good, but when i click for the second time on publish, the new row created update the last row and don’t add the new row after the last row. When i click on publish i would like to associate a group on the rows created with a number incremented.
The code :
<?if(have_rows('dates_list', $post_id)) :
// Start = field_58aec622cb824
// Stop = field_58aec632cb825
// Location = field_593a4c7708257
// Location Url = field_592d352d92940
$date = array();
$date['start'] = strtotime($_POST['acf']['field_593f9ba8c38c3']);
$date['stop'] = strtotime($_POST['acf']['field_593f9bf5c38c4']);
$location = $_POST['acf']['field_593f9c0cc38c5'];
$website_url = $_POST['acf']['field_593f9c2cc38c6'];
$compteur = array();
$compteur['number'] = $_POST['acf']['field_593e9e67be628'];
if ($_POST['acf']['field_593e9e67be628'] == NULL) {
$compteur['number'] = 0;
}
$compteur['number']++;
$datediff = $date['stop'] - $date['start'];
$days = floor($datediff / (60 * 60 * 24));
if($days > 0) :
for( $i = 0 ; $i <= $days ; $i++ ) :
$date = new DateTime( $_POST['acf']['field_593f9ba8c38c3'] );
$date->modify('+'.$i.' day');
$next_date = $date->format('Ymd');
// dates sub array
// field_578e9306be4ca = location
// field_578e92cdbe4c7 = date
$row[] = array('field_578e92cdbe4c7' => $next_date, 'field_593aac5ff4f67' => $location, 'field_592d356a92941' => $website_url, 'field_593e9e67be628' => $compteur);
$add = add_row('field_578e92a1be4c6', $row);
endfor;
update_field('field_578e92a1be4c6', $row, $post_id);
endif;
// endforeach;
// endif;
endif;
}
Thank for the help.
Screen:
Hi, it’s ok now but i have a new problem :
i need to check if the “current_value” is equal to “test-selecteur” and add selected to the equal value.
I think i need have a loop in Jquery to compare and add selected to the correct value.
Thank you for help