Opened 3 years ago
Last modified 20 months ago
#1393 new Defect
cannot print integer radio labels.
| Reported by: | izap | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Elgg 1.9.0 |
| Component: | UI/UX | Version: | Github Master |
| Severity: | minor | Keywords: | ui |
| Cc: | brettp | Difficulty: | trivial |
Description
I have following array to be used as options for a radio group.
Array
(
[svn:4] => opt:1
[svn:6] => opt:2
[None of above] => opt:3
)
It was expected to be printed like:
radio: 4
radio: 6
radio: None of above
But the result was
radio: opt:4[[BR]]
radio: opt:6[[BR]]
radio: None of above
Possible fix i did
In default/input/radio.php
$labelint = (int) $label;
if ("{$label}" == "{$labelint}") {
$label = $option;
}
There is no need of above script.
Attachments (1)
Change History (10)
Changed 3 years ago by izap
comment:1 Changed 3 years ago by izap
- Type changed from confirmed defect to fixed in attachment
comment:2 Changed 3 years ago by brettp
- Keywords ui added
- Milestone changed from Elgg 1.7 to Elgg 1.8
comment:3 Changed 3 years ago by cash
(In [svn:6626]) Refs #1393 - tried to make the ugly hack comprehensible and added a note that this will be deprecated in Elgg 1.8
comment:4 Changed 3 years ago by ewinslow
Why are the labels the keys rather than the values being the keys?
comment:5 Changed 3 years ago by cash
Maybe trying to be consistent with checkboxes where you can have the same value multiple times?
comment:6 Changed 3 years ago by cash
I take that back - values must be unique with the checkboxes view.
comment:7 Changed 2 years ago by cash
- Component changed from Core to UI/UX
- Difficulty set to trivial
- Milestone changed from Elgg 1.8 to Elgg 1.9
- Summary changed from can not print integer radio labels. to cannot print integer radio labels.
I believe the options array is label => value to support passing an indexed array of values - which also requires the hack that caused this bug. We're removing the hack (it's deprecated in 1.8). It is harder to change the order because it breaks all plugins that use checkboxes and radio inputs.
I tried to get integer labels with the current code. Using $options1? = 'value1' did not work because PHP automatically casts '1' to 1. The only way I could do this was to use character codes like 1
As we do have a work around and the problem is due to deprecated code, I'm pushing this back to 1.9.
comment:8 Changed 2 years ago by cash
(In [svn:8156]) Refs #1393 added work around note to checkboxes and radio inputs for integer labels
comment:9 Changed 20 months ago by cash
- Milestone changed from Near Term Future Release to Elgg 1.9.0

default/input/radio.php file without the described script.