$options = null;
} else {
list($name, $type, $options) = split(' *', $field);
- if($options) $options = split(',', $options);
+ if($options) $options = explode(',', $options);
if(!$type) $type = $name;
}
$input = field_input($type);
return true;
}
+function pulldown_options_array($options) {
+ if($options) {
+ $pulldown_options = array();
+ foreach($options as $option) {
+ $option = preg_replace("/['\\\\]/", '\\\\$0', $option);
+ $pulldown_options[] = "'$option'";
+ }
+ $pulldown_options = 'array(' . join(', ', $pulldown_options) . ')';
+ } else {
+ $pulldown_options = "array(array('op1', 'Option One'), array('op2', 'Option Two'), 'n/a')";
+ }
+
+ return $pulldown_options;
+}
+
function make_php() {
$has_html_editors = false;
$tem = new tem();
$always_field = find_always_field($fields);
$image_included_yet = false;
foreach($fields as $field) {
- list($name, $type, $input, $format, $sql) = $field;
+ list($name, $type, $input, $format, $sql, $options) = $field;
if($input != 'submit') {
$tem->set('format', $format);
$tem->set('name', $name);
if($input == 'html') {
$has_html_editors = true;
} elseif($input == 'pulldown' || $input == 'radio') {
+ $pulldown_options = pulldown_options_array($options);
+ $tem->set('pulldown_options', $pulldown_options);
$tem->show('pulldowns');
$tem->show('pulldown_format_extra');
}
}
$fields = get_fields();
foreach($fields as $field) {
- list($name, $type, $input, $format, $sql) = $field;
+ list($name, $type, $input, $format, $sql, $options) = $field;
if($type == 'pulldown' || $type == 'radio') {
- pulldown($name, array('option 1', 'option 2', 'option 3'));
+ pulldown($name, eval('return ' . pulldown_options_array($options) . ';'));
}
}
$preview = $preview_tem->run();