aboutsummaryrefslogtreecommitdiff
path: root/classes/helpers
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-24 15:53:45 -0300
committerSilvio <silvio@devlet.com.br>2010-08-24 15:53:45 -0300
commite3e32378e9c75303d32c7c7af92852884f73afa0 (patch)
tree73b1709b20c4bc5bf3be7abd5c92743b5629297f /classes/helpers
parent55016ae8470f0afa5f49addb70ffb07e81f893d8 (diff)
downloadcinisis-e3e32378e9c75303d32c7c7af92852884f73afa0.tar.gz
cinisis-e3e32378e9c75303d32c7c7af92852884f73afa0.tar.bz2
Using radio buttons for field and subfield selection on apps
Diffstat (limited to 'classes/helpers')
-rw-r--r--classes/helpers/CinisisDisplayHelper.php59
1 files changed, 58 insertions, 1 deletions
diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php
index 2f8fa65..0eb8d28 100644
--- a/classes/helpers/CinisisDisplayHelper.php
+++ b/classes/helpers/CinisisDisplayHelper.php
@@ -407,7 +407,7 @@ class CinisisDisplayHelper {
* @param $items
* Array with items to be merged.
*/
- protected function webMergeCsvItems($items) {
+ protected static function webMergeCsvItems($items) {
if (!empty($items)) {
self::csv(implode(';', $items));
}
@@ -415,4 +415,61 @@ class CinisisDisplayHelper {
self::csv();
}
}
+
+ /**
+ * Renders a radio button.
+ *
+ * @param $name
+ * Radio name.
+ *
+ * @param $value
+ * Radio value.
+ *
+ * @param $caption
+ * Radio caption.
+ *
+ * @param $checked
+ * Whether the radio is checked.
+ *
+ * @return
+ * HTML rendered radio button.
+ */
+ protected static function webRadio($name, $value, $caption, $checked = NULL) {
+ return '<input type="radio" name="'. $name .'" value="'. $value .'" '. $checked .' > '. $caption .'<br />';
+ }
+
+ /**
+ * Draws a combination of radio buttons.
+ *
+ * @param $name
+ * Radio names.
+ *
+ * @param $data
+ * Array with values and captions.
+ *
+ * @param $checked
+ * Index of the selected option.
+ */
+ protected static function webRadios($name, $data, $checked = NULL) {
+ $radios = '<table><tr><td>';
+ $count = 0;
+
+ foreach ($data as $key => $value) {
+ if ($count++ > 5) {
+ $count = 0;
+ $radios .= '</td><td>';
+ }
+
+ if ($key == $checked) {
+ $radios .= self::webRadio($name, $key, $value, 'checked');
+ }
+ else {
+ $radios .= self::webRadio($name, $key, $value);
+ }
+ }
+
+ $radios .= '</td></tr></table>';
+
+ return $radios;
+ }
}