Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97599668
AphrontFormCheckboxControl.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 5, 14:52
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 14:52 (2 d)
Engine
blob
Format
Raw Data
Handle
23360411
Attached To
rPH Phabricator
AphrontFormCheckboxControl.php
View Options
<?php
final
class
AphrontFormCheckboxControl
extends
AphrontFormControl
{
private
$boxes
=
array
();
public
function
addCheckbox
(
$name
,
$value
,
$label
,
$checked
=
false
)
{
$this
->
boxes
[]
=
array
(
'name'
=>
$name
,
'value'
=>
$value
,
'label'
=>
$label
,
'checked'
=>
$checked
,
);
return
$this
;
}
protected
function
getCustomControlClass
()
{
return
'aphront-form-control-checkbox'
;
}
protected
function
renderInput
()
{
$rows
=
array
();
foreach
(
$this
->
boxes
as
$box
)
{
$id
=
celerity_generate_unique_node_id
();
$checkbox
=
phutil_tag
(
'input'
,
array
(
'id'
=>
$id
,
'type'
=>
'checkbox'
,
'name'
=>
$box
[
'name'
],
'value'
=>
$box
[
'value'
],
'checked'
=>
$box
[
'checked'
]
?
'checked'
:
null
,
'disabled'
=>
$this
->
getDisabled
()
?
'disabled'
:
null
,
));
$label
=
phutil_tag
(
'label'
,
array
(
'for'
=>
$id
,
),
$box
[
'label'
]);
$rows
[]
=
hsprintf
(
'<tr><td>%s</td><th>%s</th></tr>'
,
$checkbox
,
$label
);
}
return
phutil_tag
(
'table'
,
array
(
'class'
=>
'aphront-form-control-checkbox-layout'
),
$rows
);
}
}
Event Timeline
Log In to Comment