setopt -o OCTAL_ZEROES 2>&-
form_radio(){
+ # Produce a single radio button and an associated label
# Usage: form_radio Name Value Condition Label
# if "Condition" is the same as "Value", the button will be checked
}
form_check(){
+ # Produce a checkbox and an associated label
# Usage: form_check Name Value Condition Label
# if "Condition" is the same as "Value", the Checkbox will be checked
printf '<input type="checkbox" id="%s" name="%s" value="%s" %s /><label for="%s">%s</label>' \
"$id" "$name" "$value" "$check" "$id" "$label"
}
+
+form_radio_list(){
+ # Produce a group of radio buttons
+ # Buttons can be given in the form label/value either as parameters,
+ # or as lines on stdin
+ # if hte button value matches cond, this button will be selected
+
+ name="$1"
+ cond="$2"
+ shift 2
+
+ if [ -n "$*" ]; then for each in "$@"; do
+ form_radio "$name" "${each##*/}" "$cond" "${each%/*}"
+ done; else while read each; do
+ form_radio "$name" "${each##*/}" "$cond" "${each%/*}"
+ done; fi
+}