From 5b75cd1f5c479ada468fbf62a733c54edad152f1 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 5 Jan 2010 14:14:00 +0100 Subject: New mail subscription with digest --- inc/form.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'inc/form.php') 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 + */ + + 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)); + } + } + } /** -- cgit v1.2.3