davez
Member
I've got a repeatable group with a date element that uses the PHP Allow date function, that uses AJAX and 'watches' the previous element in the group. It works fine for the first repeat, but in subsequent repeats, it pulls from the first group element in the watch list. Here's the code from the PHP Allow date function in the date element:
Again, it works fine for the first repeat, but with the next added repeat group, the watch element it chooses from is from the first repeat, not from the current one.
I might be asking too much of this feature for it to work with in a repeat. Or maybe there's a variable I can pull the current repeat data from rather than from $input. I'm not finding the current repeat data in $input when I var_dump($input).
Thoughts?
Code:
$db = JFactory::getDBO();
$input = JFactory::getApplication()->input;
$site_id = JArrayHelper::getValue($data, 'wic_itinerary___site_id_raw', 0);
$ajax_site_id = $input->get('v', $id);
$site_id = $ajax_site_id;
$query = "SELECT dates_offered FROM wic_sites where id = '".$site_id."'" ;
$db->setQuery($query);
$dates_allowed = $db->loadResult();
$dates_allowed = str_replace(' ', '', $dates_allowed );
$date_array = explode(',', $dates_allowed);
$temp_date = $date_array[0];
$d = DateTime::createFromFormat('Y-m-d', $temp_date);
if ($d && $d->format('Y-m-d') === $temp_date) return $date_array;
I might be asking too much of this feature for it to work with in a repeat. Or maybe there's a variable I can pull the current repeat data from rather than from $input. I'm not finding the current repeat data in $input when I var_dump($input).
Thoughts?