Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/form/control/AphrontFormSubmitControl.php
12262 views
1
<?php
2
3
final class AphrontFormSubmitControl extends AphrontFormControl {
4
5
private $buttons = array();
6
private $sigils = array();
7
8
public function addCancelButton($href, $label = null) {
9
if (!$label) {
10
$label = pht('Cancel');
11
}
12
$button = id(new PHUIButtonView())
13
->setTag('a')
14
->setHref($href)
15
->setText($label)
16
->setColor(PHUIButtonView::GREY);
17
$this->addButton($button);
18
return $this;
19
}
20
21
public function addButton(PHUIButtonView $button) {
22
$this->buttons[] = $button;
23
return $this;
24
}
25
26
public function addSigil($sigil) {
27
$this->sigils[] = $sigil;
28
return $this;
29
}
30
31
protected function getCustomControlClass() {
32
return 'aphront-form-control-submit';
33
}
34
35
protected function renderInput() {
36
$submit_button = null;
37
if ($this->getValue()) {
38
39
if ($this->sigils) {
40
$sigils = $this->sigils;
41
} else {
42
$sigils = null;
43
}
44
45
$submit_button = javelin_tag(
46
'button',
47
array(
48
'type' => 'submit',
49
'name' => '__submit__',
50
'sigil' => $sigils,
51
'disabled' => $this->getDisabled() ? 'disabled' : null,
52
),
53
$this->getValue());
54
}
55
56
return array(
57
$submit_button,
58
$this->buttons,
59
);
60
}
61
62
}
63
64