diff options
author | Adrian Lang <lang@cosmocode.de> | 2010-01-05 14:14:00 +0100 |
---|---|---|
committer | Adrian Lang <lang@cosmocode.de> | 2010-01-20 10:53:18 +0100 |
commit | 5b75cd1f5c479ada468fbf62a733c54edad152f1 (patch) | |
tree | 7ca6012d892aaef60cee7bc86b2f62ade43e03ce /inc/form.php | |
parent | b5ee21aa65a2f380e3b99ff5ea6ced48c1cb720e (diff) | |
download | rpg-5b75cd1f5c479ada468fbf62a733c54edad152f1.tar.gz rpg-5b75cd1f5c479ada468fbf62a733c54edad152f1.tar.bz2 |
New mail subscription with digest
Diffstat (limited to 'inc/form.php')
-rw-r--r-- | inc/form.php | 21 |
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)); + } + } + } /** |