Disable Date Once Passed

LikeStuff 19 Oct, 2015
Hello,

Can someone please help me with this.

I have a field called signup_dates. I am using a checkbox group for this field. Is there a way to disable a date once it's passed? Or if there a better way to do this?

I just want the dates listed and once the date has passed the user can no longer select that date.

Thank you!
GreyHead 20 Oct, 2015
Hi LikeStuff,

Use the Dynamic Data option in the Checkbox Group action to create the checkboxes, this will use data from a sub-array in the $form->data[''] array so you can build that with a Custom Code action something like this
<?php
Sdates = array(
  'event_1 => '2015-12-12',
  'event_2' => '2015-11-11',
  . . .
}
$now = new DateTime();
$boxes = array();
foreach ( $dates as $k => $v ) {
  $event_date = new DateTime($v);
  if ( $event_date < $now ) {
    continue;
  }
  $boxes[] = array( 'event' => $k, 'date' => $v);
}
$form->data['boxes'] = $boxes;  
?>
Then use boxes, event and date in the Dynamic Options.
Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger