-
Notifications
You must be signed in to change notification settings - Fork 554
/
Checkbox.php
64 lines (49 loc) · 1.52 KB
/
Checkbox.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace A17\Twill\Services\Forms\Fields;
use A17\Twill\Services\Forms\Fields\Traits\HasBorder;
use A17\Twill\Services\Forms\Fields\Traits\IsTranslatable;
class Checkbox extends BaseFormField
{
use IsTranslatable;
use HasBorder;
protected ?string $confirmMessageText = null;
protected ?string $confirmTitleText = null;
protected bool $requireConfirmation = false;
public static function make(): static
{
return new self(
component: \A17\Twill\View\Components\Fields\Checkbox::class,
mandatoryProperties: ['name', 'label']
);
}
/**
* The message to show when confirming the checking of the checkbox.
*/
public function confirmMessageText(string $confirmMessageText): static
{
$this->confirmMessageText = $confirmMessageText;
if (!$this->requireConfirmation) {
$this->requireConfirmation();
}
return $this;
}
/**
* The title to show when confirming the checking of the checkbox.
*/
public function confirmTitleText(string $confirmTitleText): static
{
$this->confirmTitleText = $confirmTitleText;
if (!$this->requireConfirmation) {
$this->requireConfirmation();
}
return $this;
}
/**
* If the checkbox needs confirmation on ticking.
*/
public function requireConfirmation(bool $requireConfirmation = true): static
{
$this->requireConfirmation = $requireConfirmation;
return $this;
}
}