-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.php
75 lines (62 loc) · 1.65 KB
/
Button.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
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Onimla\HTML;
class Button extends Element {
use Traits\Name;
function __construct($text = FALSE, $type = 'button') {
parent::__construct('button');
$this->type($type);
$this->text($text);
$this->selfClose(FALSE);
}
/**
* Specifies the value of an input element
* @see http://www.w3schools.com/tags/att_input_value.asp
* @param string $value the value of the element
* @return string|Button the current value of the element OR method chaining
*/
function value($value = FALSE) {
return $this->attr('value', $value);
}
/**
* @param string $value
* @return string|Button
*/
function type($value = NULL) {
return $this->attr('type', $value, 'safe');
}
/**
* @param string $value
* @return string|Button
*/
public function form($value = FALSE) {
if (is_object($value) AND is_callable(array($value, 'id'))) {
$value = ($value->id() === FALSE AND is_callable(array($value, 'uniqid'))) ? $value->uniqid()->id() : $value->id();
}
return $this->attr('form', $value, 'safe');
}
/**
* @return bool
*/
public function enabled() {
return !$this->attr('disabled');
}
/**
* @return bool
*/
public function disabled() {
return (bool) $this->attr('disabled');
}
/**
* @return Button
*/
public function enable() {
return $this->removeAttr('disabled');
}
/**
*
* @return Button
*/
public function disable() {
return $this->attr('disabled', 'disabled');
}
}