aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-20 09:28:42 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-20 09:28:42 +0000
commite61a98c5dd04391db3eb7e3a087de633e2a6b0fe (patch)
tree6b0242434d6e2879ef309f2aee4a1f06ada47486 /views/default
parent0be1be0cdecefc9fc7c89c736525ee0dff1565c6 (diff)
downloadelgg-e61a98c5dd04391db3eb7e3a087de633e2a6b0fe.tar.gz
elgg-e61a98c5dd04391db3eb7e3a087de633e2a6b0fe.tar.bz2
Fixes #2396: Added a new input/checkbox view. input/checkboxes harnesses it
git-svn-id: http://code.elgg.org/elgg/trunk@7372 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default')
-rw-r--r--views/default/input/checkbox.php18
-rw-r--r--views/default/input/checkboxes.php44
2 files changed, 30 insertions, 32 deletions
diff --git a/views/default/input/checkbox.php b/views/default/input/checkbox.php
new file mode 100644
index 000000000..32bc323fd
--- /dev/null
+++ b/views/default/input/checkbox.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Elgg checkbox input
+ * Displays a checkbox input field
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$defaults = array(
+ 'class' => 'input_checkbox',
+);
+
+$vars = array_merge($defaults, $vars);
+
+?>
+
+<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> /> \ No newline at end of file
diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php
index adfe19914..46254633b 100644
--- a/views/default/input/checkboxes.php
+++ b/views/default/input/checkboxes.php
@@ -52,44 +52,24 @@ if ($options) {
$label = $option;
}
- if (!in_array(strtolower($option), $value_array)) {
- $selected = FALSE;
- } else {
- $selected = TRUE;
- }
-
- $attr = array(
- 'type="checkbox"',
- 'value="' . htmlentities($option, ENT_QUOTES, 'UTF-8') . '"'
+ $input_vars = array(
+ 'checked' => in_array(strtolower($option), $value_array),
+ 'value' => $option,
+ 'disabled' => $disabled,
+ 'id' => $id,
+ 'js' => $js,
);
-
- if ($id) {
- $attr[] = "id=\"$id\"";
- }
-
+
if ($class) {
- $attr[] = "class=\"$class\"";
- }
-
- if ($disabled) {
- $attr[] = 'disabled="yes"';
- }
-
- if ($selected) {
- $attr[] = 'checked = "checked"';
- }
-
- if ($js) {
- $attr[] = $js;
+ $input_vars['class'] = $class;
}
if ($internalname) {
- // @todo this really, really should only add the []s if there are > 1 element in options.
- $attr[] = "name=\"{$internalname}[]\"";
+ $input_vars['name'] = "{$internalname}[]";
}
+
+ $input = elgg_view('input/checkbox', $input_vars);
- $attr_str = implode(' ', $attr);
-
- echo "<label><input $attr_str />$label</label><br />";
+ echo "<label>{$input}{$label}</label><br />";
}
} \ No newline at end of file