aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/radio.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-07-02 09:21:30 -0400
committerCash Costello <cash.costello@gmail.com>2011-07-02 09:21:30 -0400
commitf5f3f205e97c2a3219897dd14de7d57659ce1181 (patch)
treee89da8c8aa003826b1815cabaf01d1fbcfbb351f /views/default/input/radio.php
parent9e9b28479b6ecfd8685b2bba7f9ae5856ece9b2e (diff)
downloadelgg-f5f3f205e97c2a3219897dd14de7d57659ce1181.tar.gz
elgg-f5f3f205e97c2a3219897dd14de7d57659ce1181.tar.bz2
Fixes #3624 input views use class extending rather than overriding
Diffstat (limited to 'views/default/input/radio.php')
-rw-r--r--views/default/input/radio.php47
1 files changed, 33 insertions, 14 deletions
diff --git a/views/default/input/radio.php b/views/default/input/radio.php
index 0ad28423f..befba392a 100644
--- a/views/default/input/radio.php
+++ b/views/default/input/radio.php
@@ -10,24 +10,43 @@
* @package Elgg
* @subpackage Core
*
- * @uses $vars['value'] The current value, if any
- * @uses $vars['name'] 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['class'] Additional class of the list. Optional.
- * @uses $vars['align'] 'horizontal' or 'vertical' Default: 'vertical'
+ * @uses $vars['value'] The current value, if any
+ * @uses $vars['name'] 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['class'] Additional class of the list. Optional.
+ * @uses $vars['align'] 'horizontal' or 'vertical' Default: 'vertical'
*/
-$additional_class = elgg_extract('class', $vars);
-$align = elgg_extract('align', $vars, 'vertical');
-$class = "elgg-input-radio elgg-$align";
-if ($additional_class) {
- $class = " $additional_class";
+$defaults = array(
+ 'align' => 'vertical',
+ 'value' => array(),
+ 'disabled' => false,
+ 'options' => array(),
+ 'name' => '',
+);
+
+$vars = array_merge($defaults, $vars);
+
+$id = '';
+if (isset($vars['id'])) {
+ $id = "id=\"{$vars['id']}\"";
+ unset($vars['id']);
+ unset($vars['internalid']);
+}
+
+$class = "elgg-input-radios elgg-{$vars['align']}";
+if (isset($vars['class'])) {
+ $class .= " {$vars['class']}";
unset($vars['class']);
}
+unset($vars['align']);
+$vars['class'] = 'elgg-input-radio';
-if (isset($vars['align'])) {
- unset($vars['align']);
+if (is_array($vars['value'])) {
+ $vars['value'] = array_map('elgg_strtolower', $vars['value']);
+} else {
+ $vars['value'] = array(elgg_strtolower($vars['value']));
}
$options = $vars['options'];
@@ -37,7 +56,7 @@ $value = $vars['value'];
unset($vars['value']);
if ($options && count($options) > 0) {
- echo "<ul class=\"$class\">";
+ echo "<ul class=\"$class\" $id>";
foreach ($options as $label => $option) {
$vars['checked'] = elgg_strtolower($option) == elgg_strtolower($value);