From fb68b74032f7f394f504f74a83cba1e36155ae3a Mon Sep 17 00:00:00 2001 From: ewinslow Date: Sat, 12 Feb 2011 07:16:02 +0000 Subject: Fixes #2143: DRYed up input/radio -- other views still should be addressed, but not because they aren't DRY, therefore I'm calling this ticket closed git-svn-id: http://code.elgg.org/elgg/trunk@8149 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/radio.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'views/default/input') diff --git a/views/default/input/radio.php b/views/default/input/radio.php index 9f4c71d32..c897b48f1 100644 --- a/views/default/input/radio.php +++ b/views/default/input/radio.php @@ -13,29 +13,30 @@ * */ -$class = $vars['class']; -if (!$class) { - $class = "elgg-input-radio"; -} +$defaults = array( + 'class' => 'elgg-input-radio', +); -foreach ($vars['options'] as $label => $option) { - if (strtolower($option) != strtolower($vars['value'])) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } +$vars = array_merge($defaults, $vars); + +$options = $vars['options']; +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 (isset($vars['internalid'])) { - $id = "id=\"{$vars['internalid']}\""; - } - if ($vars['disabled']) { - $disabled = ' disabled="yes" '; - } - echo "
"; + echo "
"; } \ No newline at end of file -- cgit v1.2.3