'money' => array('textbox', 'money', 'varchar(32)'),
'dollars' => array('textbox', 'dollars', 'varchar(32)'),
'url' => array('textbox', 'url', 'varchar(200)'),
+ 'hidden' => array('hidden', 'unix', 'varchar(200)'),
+ 'password' => array('password', 'oneline', 'varchar(200)'),
'textarea' => array('textarea', 'unix', 'text'),
'pulldown' => array('pulldown', 'options', 'int'),
- 'checkbox' => array('checkbox', 'yesno', 'int'),
- 'yesno' => array('checkbox', 'yesno', 'int'),
+ 'checkbox' => array('checkbox', 'yesno', 'varchar(3)'),
+ 'yesno' => array('checkbox', 'yesno', 'varchar(3)'),
+ 'delete' => array('checkbox', 'yesno', 'n/a'),
+ 'image' => array('image', 'oneline', 'varchar(200)'),
'submit' => array('submit', 'oneline', 'n/a')
);
return $ret;
}
+# this one, that you're using to create forms
function set_form_action() {
$action = ereg_replace('.*/', '', $_SERVER['REQUEST_URI']);
if($action == '') $action = './';
# pass false if you want to exclude the <head> and <body> tag etc.
function make_template($whole_file = true) {
+ $uploads_output_already = false;
$tem = new tem();
$tem->load('code/wfpl/metaform/template.html');
$tem->set('form_name', $GLOBALS['form_name']);
$tem->set('name', $name);
$tem->set('caption', $name); # fixme
$tem->sub($input);
- $tem->sub('row');
+ if($input != 'hidden') {
+ $tem->sub('row');
+ }
+ if($input == 'image' && !$uploads_output_already) {
+ $tem->sub('uploads');
+ $tem->set('enctype_attr', '" enctype="multipart/form-data');
+ $uploads_output_already = true;
+ }
}
$tem->set('name', 'save');
$tem->set('caption', 'Save');
$tem->set('form_name', $GLOBALS['form_name']);
$fields = get_fields();
$db_fields = '';
+ $php_fields = '';
$always_field = false;
+ $image_included_yet = false;
foreach($fields as $field) {
list($name, $type, $input, $format, $sql) = $field;
if($input != 'submit') {
$tem->set('name', $name);
$tem->set('db_field', ''); # we don't want to use the value from last time
if($sql != 'n/a') {
- $tem->sub('db_field');
if($db_fields != '') $db_fields .= ',';
$db_fields .= $name;
+ if($php_fields != '') $php_fields .= ', ';
+ $php_fields .= '$' . $name;
+ }
+ if($input == 'image') {
+ $tem->sub('image_upload');
+ $tem->sub('image_db');
+ if(!$image_included_yet) {
+ $tem->sub('image_include');
+ $tem->sub('upload_max');
+ $tem->sub('upload_settings');
+ $image_included_yet = true;
+ }
+ } else {
+ $tem->sub('formats');
+ $tem->sub('tem_sets');
}
- $tem->sub('formats');
if(!$always_field and $input != 'checkbox' and $input != 'radio') {
$always_field = $name;
}
# always_field is a form field that always submits (unlike say, checkboxes). It's used to detect if the form has submitted or not.
$tem->set('always_field', $always_field);
$tem->set('db_fields', $db_fields);
+ $tem->set('php_fields', $php_fields);
return $tem->run();
}