-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickDatesField.php
More file actions
47 lines (40 loc) · 1.13 KB
/
QuickDatesField.php
File metadata and controls
47 lines (40 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace RockQuickDates;
use ProcessWire\WireData;
use function ProcessWire\wire;
class QuickDatesField extends WireData
{
public $options;
public function __construct()
{
// set default options
$this->options = new WireData();
$this->options->setArray([
'buttons' => 'modules/RockQuickDates/buttons/15m-1h.html',
]);
}
public function getButtonMarkup(): string
{
$buttons = wire()->files->render(
// this ensures we may use any file in the /site folder or below
wire()->config->paths->site . $this->options->buttons
);
return "
<div
quickdates-buttons
data-fieldname='{$this->name}'
data-roundto='{$this->options->roundto}'
data-connectedto='{$this->options->connectedto}'
data-connectiontype='{$this->options->connectiontype}'
data-durationfield='{$this->options->durationfield}'
data-durationtype='{$this->options->durationtype}'
>$buttons</div>
<script>RockQuickDates.init();</script>
";
}
public function setOption($key, $value): self
{
$this->options->{$key} = $value;
return $this;
}
}