Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97597869
AphrontFormRadioButtonControl.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:30
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 14:30 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23359967
Attached To
rPH Phabricator
AphrontFormRadioButtonControl.php
View Options
<?php
final
class
AphrontFormRadioButtonControl
extends
AphrontFormControl
{
private
$buttons
=
array
();
public
function
addButton
(
$value
,
$label
,
$caption
,
$class
=
null
,
$disabled
=
false
)
{
$this
->
buttons
[]
=
array
(
'value'
=>
$value
,
'label'
=>
$label
,
'caption'
=>
$caption
,
'class'
=>
$class
,
'disabled'
=>
$disabled
,
);
return
$this
;
}
protected
function
getCustomControlClass
()
{
return
'aphront-form-control-radio'
;
}
protected
function
renderInput
()
{
$rows
=
array
();
foreach
(
$this
->
buttons
as
$button
)
{
$id
=
celerity_generate_unique_node_id
();
$radio
=
phutil_tag
(
'input'
,
array
(
'id'
=>
$id
,
'type'
=>
'radio'
,
'name'
=>
$this
->
getName
(),
'value'
=>
$button
[
'value'
],
'checked'
=>
(
$button
[
'value'
]
==
$this
->
getValue
())
?
'checked'
:
null
,
'disabled'
=>
(
$this
->
getDisabled
()
||
$button
[
'disabled'
])
?
'disabled'
:
null
,
));
$label
=
phutil_tag
(
'label'
,
array
(
'for'
=>
$id
,
'class'
=>
$button
[
'class'
],
),
$button
[
'label'
]);
if
(
$button
[
'caption'
])
{
$label
=
hsprintf
(
'%s<div class="aphront-form-radio-caption">%s</div>'
,
$label
,
$button
[
'caption'
]);
}
$rows
[]
=
hsprintf
(
'<tr><td>%s</td><th>%s</th></tr>'
,
$radio
,
$label
);
}
return
phutil_tag
(
'table'
,
array
(
'class'
=>
'aphront-form-control-radio-layout'
),
$rows
);
}
}
Event Timeline
Log In to Comment