summaryrefslogtreecommitdiff
path: root/inc/form.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/form.php')
-rw-r--r--inc/form.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/inc/form.php b/inc/form.php
index 6d496f414..0a6bc2bba 100644
--- a/inc/form.php
+++ b/inc/form.php
@@ -283,6 +283,27 @@ class Doku_Form {
echo $this->getForm();
}
+ /**
+ * Add a radio set
+ *
+ * This function adds a set of radio buttons to the form. If $_POST[$name]
+ * is set, this radio is preselected, else the first radio button.
+ *
+ * @param string $name The HTML field name
+ * @param array $entries An array of entries $value => $caption
+ *
+ * @author Adrian Lang <lang@cosmocode.de>
+ */
+
+ function addRadioSet($name, $entries) {
+ $value = (isset($_POST[$name]) && isset($entries[$_POST[$name]])) ?
+ $_POST[$name] : key($entries);
+ foreach($entries as $val => $cap) {
+ $data = ($value === $val) ? array('checked' => 'checked') : array();
+ $this->addElement(form_makeRadioField($name, $val, $cap, '', '', $data));
+ }
+ }
+
}
/**