diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 07:16:02 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 07:16:02 +0000 |
commit | fb68b74032f7f394f504f74a83cba1e36155ae3a (patch) | |
tree | eed97dbd40c94238ad52f2762c81a914e0323a28 /views | |
parent | b1890228d61304bb0c4b6828af457dd9ef96f4f3 (diff) | |
download | elgg-fb68b74032f7f394f504f74a83cba1e36155ae3a.tar.gz elgg-fb68b74032f7f394f504f74a83cba1e36155ae3a.tar.bz2 |
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
Diffstat (limited to 'views')
-rw-r--r-- | views/default/input/radio.php | 35 |
1 files changed, 18 insertions, 17 deletions
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 "<label><input type=\"radio\" $disabled {$vars['js']} name=\"{$vars['internalname']}\" $id value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />"; + echo "<label><input type=\"radio\" $attributes />$label</label><br />"; }
\ No newline at end of file |