$fields_str = rtrim($fields_str);
$fields = split("\n", $fields_str);
foreach($fields as $field) {
+ $first_char = substr($field, 0, 1);
$field = trim($field);
+ if ($first_char === ' ' || $first_char === "\t") {
+ $i = count($GLOBALS['gotten_fields']);
+ if($i > 0) {
+ $i -= 1;
+ if (!$GLOBALS['gotten_fields'][$i]['options']) {
+ $GLOBALS['gotten_fields'][$i]['options'] = array();
+ }
+ $GLOBALS['gotten_fields'][$i]['options'][] = $field;
+ continue;
+ }
+ }
if(substr($field, -1) == '{') {
$caption = trim(substr($field, 0, -1));
$name = format_varname($caption);
$type = '{';
$options = null;
- # FIXME restore parsing of option lists for pulldowns
} else {
$options = null;
$type = null;
'caption' => $field['caption']
)
);
+ if($field['type'] == 'radio') {
+ $i = 0;
+ $opts = array();
+ foreach ($field['options'] as $row) {
+ if (is_array($row)) {
+ $cap = $row[1];
+ } else {
+ $cap = $row;
+ }
+ $opts[] = array('i' => $i, 'option_caption' => $cap);
+ $i += 1;
+ }
+ $visible_fields[count($visible_fields) - 1]['options'] = $opts;
+ }
}
if($field['input'] == 'image' || $field['input'] == 'file') {
<p>You can start a labeled fieldset by putting a <code>{</code> at the end of a line with the caption. Then end the fieldset with a <code>}</code> on a line by itself</p>
+ <p>Pulldown/radio options can be specified (one per line) indented below the field</p>
+
<p>Example:<br><code><pre>
email
contact info (all required) {
- name
- phone
+name
+phone
}
+pulldown color
+ Red
+ Blue
+ Black
textarea comments
yesno agree
</pre></code></p>
<div class="field"><select name="~name~"><option value="">Choose One:</option><!--~~~name~ states~~--></select></div><!--~}~--><!--~radio {~-->
<div class="caption">~caption html~</div>
<div class="field">
- <input type="radio" name="~name~" value="~~~name~ radio_0~~">~~~name~ radio_caption_0 html~~<br>
- <input type="radio" name="~name~" value="~~~name~ radio_1~~">~~~name~ radio_caption_1 html~~<br>
- <input type="radio" name="~name~" value="~~~name~ radio_2~~">~~~name~ radio_caption_2 html~~
+ <!--~options {~-->
+ <input type="radio" name="~name~" value="~~~name~ radio_~i~~~">~option_caption html~<br>
+ <!--~}~-->
</div><!--~}~--><!--~checkbox {~-->
<div class="caption"><input type="checkbox" name="~name~~~~name~ checked~~" id="~name~_checkbox"><label for="~name~_checkbox"> ~caption html~</label></div>
<div class="field"></div><!--~}~--><!--~submit {~-->