function CourseObjectAttendance::optionsForm in Course 3.x
Default options form for all course objects.
Overrides CourseObject::optionsForm
File
- modules/
course_attendance/ src/ Plugin/ course/ CourseObject/ CourseObjectAttendance.php, line 44
Class
- CourseObjectAttendance
- Plugin annotation @CourseObject( id = "attendance", label = "Attendance", )
Namespace
Drupal\course_attendance\Plugin\course\CourseObjectCode
function optionsForm(&$form, FormStateInterface $form_state) {
parent::optionsForm($form, $form_state);
$config = $this
->getOptions();
/* @var $duration \Drupal\duration_field\Service\DurationService */
$duration = \Drupal::service('duration_field.service');
$form['instance'] = [
'#type' => 'textfield',
'#title' => t('Attendance code'),
'#description' => t('Randomly generated when this signup is created, but you can change it here.'),
'#default_value' => $config['instance'],
];
$form['open']['#type'] = 'container';
$form['open']['#prefix'] = '<div class="container-inline">';
$form['open']['#suffix'] = ' start date</div>';
$form['open']['open'] = array(
'#title' => t('Open attendance'),
'#type' => 'duration',
'#granularity' => 'd:h:i',
'#default_value' => $duration
->getDurationStringFromDateInterval($this
->secondsToInterval(abs($config['open']))),
);
$form['open']['open_direction'] = array(
'#title' => t(''),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => array(
1 => 'after',
-1 => 'before',
),
'#default_value' => $config['open'] > 1 ? 1 : -1,
);
$form['close']['#type'] = 'container';
$form['close']['#prefix'] = '<div class="container-inline">';
$form['close']['#suffix'] = ' start date</div>';
$form['close']['close'] = array(
'#title' => t('Close attendance'),
'#type' => 'duration',
'#granularity' => 'd:h:i',
'#default_value' => $duration
->getDurationStringFromDateInterval($this
->secondsToInterval(abs($config['close']))),
);
$form['close']['close_direction'] = array(
'#title' => t(''),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => array(
1 => 'after',
-1 => 'before',
),
'#default_value' => $config['close'] > 1 ? 1 : -1,
);
$form['reset'] = array(
'#title' => 'Reset code',
'#description' => t('Check this to randomly generate a new code.'),
'#type' => 'checkbox',
);
}