aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/radio.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 14:02:11 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 14:02:11 +0000
commit3d95a51f3f8771d9c52c888bcc4eddf88f18a8ca (patch)
treec4a12860b47220b4c0cac22a5ca794cb12042f0e /views/default/input/radio.php
parent67ee3bc241e70aaffd451452e9761ed512dc52aa (diff)
downloadelgg-3d95a51f3f8771d9c52c888bcc4eddf88f18a8ca.tar.gz
elgg-3d95a51f3f8771d9c52c888bcc4eddf88f18a8ca.tar.bz2
Fixes #972 checkboxes and radio input fields support horizontal and vertical alignments
git-svn-id: http://code.elgg.org/elgg/trunk@8154 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/input/radio.php')
-rw-r--r--views/default/input/radio.php56
1 files changed, 34 insertions, 22 deletions
diff --git a/views/default/input/radio.php b/views/default/input/radio.php
index c897b48f1..924411aa8 100644
--- a/views/default/input/radio.php
+++ b/views/default/input/radio.php
@@ -6,18 +6,25 @@
* @package Elgg
* @subpackage Core
*
- * @uses $vars['value'] The current value, if any
- * @uses $vars['js'] Any Javascript to enter into the input tag
+ * @uses $vars['value'] The current value, if any
* @uses $vars['internalname'] The name of the input field
- * @uses $vars['options'] An array of strings representing the options for the radio field as "label" => option
- *
+ * @uses $vars['options'] An array of strings representing the options for the
+ * radio field as "label" => option
+ * @uses $vars['class'] Additional class of the list. Optional.
+ * @uses $vars['align'] 'horizontal' or 'vertical' Default: 'vertical'
*/
-$defaults = array(
- 'class' => 'elgg-input-radio',
-);
+$additional_class = elgg_get_array_value('class', $vars);
+$align = elgg_get_array_value('align', $vars, 'vertical');
+$class = "elgg-input-radio elgg-$align";
+if ($additional_class) {
+ $class = " $additional_class";
+ unset($vars['class']);
+}
-$vars = array_merge($defaults, $vars);
+if (isset($vars['align'])) {
+ unset($vars['align']);
+}
$options = $vars['options'];
unset($vars['options']);
@@ -25,18 +32,23 @@ unset($vars['options']);
$value = $vars['value'];
unset($vars['value']);
-foreach ($options as $label => $option) {
-
- $vars['checked'] = strtolower($option) != strtolower($vars['value']);
- $vars['value'] = $option;
-
- $attributes = elgg_format_attributes($vars);
-
- // handle indexed array where label is not specified
- // @todo deprecate in Elgg 1.8
- if (is_integer($label)) {
- $label = $option;
+if ($options && count($options) > 0) {
+ echo "<ul class=\"$class\">";
+ foreach ($options as $label => $option) {
+
+ $vars['checked'] = elgg_strtolower($option) != elgg_strtolower($vars['value']);
+ $vars['value'] = $option;
+
+ $attributes = elgg_format_attributes($vars);
+
+ // handle indexed array where label is not specified
+ // @deprecated 1.8
+ if (is_integer($label)) {
+ elgg_deprecated_notice('$vars[\'options\'] must be an associative array in input/radio', 1.8);
+ $label = $option;
+ }
+
+ echo "<li><label><input type=\"radio\" $attributes />$label</label></li>";
}
-
- echo "<label><input type=\"radio\" $attributes />$label</label><br />";
-} \ No newline at end of file
+ echo '</ul>';
+}