Date picker issues in latest Fabrikar

kootjoo

Member
Hi,

In my sites I used the "Allowed Date Function" and the "PHP Allowed Date function" next to each other to block some dates. I use following code:

Allowed Date Function (to Block Sunday and Monday)
var date = new Date(date);
/* Check if this is a weekend */
var dayOfWeek = date.getDay();
if (dayOfWeek === 0 || dayOfWeek == 6 )
{ result = true; }
else
{ result = false; }

PHP Allowed Date Function (to block days that are set in separate table)

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select ('DATE(datum)')
->from('volgeboekt');
$myDb->setQuery($myQuery);
$bookedDates = $myDb->loadColumn();

$begin = new DateTime();
$end = new DateTime('2020-12-31');

$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);

$myAllowedDates = array();

foreach( $period as $dt ) {
$thisDate = $dt->format("Y-m-d");
if (!in_array($thisDate, $bookedDates)) {
$myAllowedDates[] = $thisDate;
}
}
return $myAllowedDates;

This used to work without issues. I now have upgraded Fabrikar to latetst 3.8.1 version and it stopped working only one of the functions works but not both at same time.

Is this normal in new version?
 
Which one still works?

What version of Fabrik did you update from?

Can you point me at the page?

-- hugh
 
The tooltip says "set a variable called 'result' to true to stop this date from being selected.<br />set a variable called 'result' to false to allow this date to be selected, or to a class name if you want that class name to be applied to that cell on the calendar."

So try if setting the class directly to "disabled" is working
if (dayOfWeek === 0 || dayOfWeek == 6 )
{ result = "disabled"; }
 
OK, yup, I see the issue, in this commit, as pointed out by @troester ...

https://github.com/Fabrik/fabrik/commit/d67f662a2828cde223be749f1e74b37b58d1ece9

... where I added being able to set a class in the PHP method, by having the date as "xxxx-xx-xx|classname" rather than just "xxxx-xx-xx". Before that change, if PHP allowed the date, it would then drop through and let the JS have a chance to disallow it. The change meant that if there was a PHP method, it never allowed the JS to run.

I've applied a kinda-sorta fix in this commit:

https://github.com/Fabrik/fabrik/commit/9c76df02b4f9089035f462deb95f1d990a47f3fa

... which reverts to the old behavior if you don't specify the optional class in the PHP allowed date.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top