Time element range

leblancphil

Member
Hello,
I use a time element, works fine, but I would like to limit the range of hours, for example from 9 AM to 10 PM.
How could I do this ?
Thanks for your help.
 
You'd probably have to override the layout.

So copy ...

fabrik-element-time-form.php

... to the appropriate layout override folder, see wiki but probably in a named element location like ...

components/com_fabrik/views/form/tmpl/bootstrap/layouts/element/yourtable___yourelement

... so it only affects that element, not all time elements, and twiddle the code to build the menu you want for hours. Something like this near the top, after $d has been set up ...

Code:
// remove all hours array entries outside our range
foreach ($d->hours as $k => $h) {
   if ((int)$h->value < 9 || (int)$h->value > 22) {
      unset($h[$k]);
   }
}

... or you could disable the hours you don't want, rather than removing them ...

Code:
// disable all hours array entries outside our range
foreach ($d->hours as $k => &$h) {
   if ((int)$h->value < 9 || (int)$h->value > 22) {
      $h->disable = true;
   }
}

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

Thank you.

Members online

Back
Top