From b54ae765dff4e8a1b3c9a8d1f342ecc497ce95b4 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Tue, 9 Dec 2008 14:11:18 -0500 Subject: [PATCH] added "singular" field, so metaform can generate better messages, links and headers --- metaform.php | 7 ++++++- metaform/main.html | 4 +++- metaform/preview.html | 4 ++-- metaform/template.html | 20 ++++++++++---------- metaform/template.php | 8 ++++---- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/metaform.php b/metaform.php index 734d8fc..81ac452 100644 --- a/metaform.php +++ b/metaform.php @@ -69,7 +69,9 @@ function list_available_types() { function metaform() { if(isset($_REQUEST['form_name'])) { - $GLOBALS['form_name'] = ereg_replace('[^a-z0-9_-]', '', $_REQUEST['form_name']); + $GLOBALS['form_name'] = format_varname($_REQUEST['form_name']); + $GLOBALS['singular'] = format_varname($_REQUEST['singular']); + tem_set('singular', $GLOBALS['singular']); $GLOBALS['opt_email'] = format_yesno($_REQUEST['opt_email']); tem_set('opt_email', $GLOBALS['opt_email']); $GLOBALS['opt_db'] = format_yesno($_REQUEST['opt_db']); @@ -210,6 +212,7 @@ function make_html($whole_file = true) { $tem = new tem(); $tem->load('code/wfpl/metaform/template.html'); $tem->set('form_name', $GLOBALS['form_name']); + $tem->set('singular', $GLOBALS['singular']); $fields = get_fields(); $tem->set('always_field', find_always_field($fields)); foreach($fields as $field) { @@ -296,6 +299,7 @@ function make_php() { $tem = new tem(); $tem->load('code/wfpl/metaform/template.php'); $tem->set('form_name', $GLOBALS['form_name']); + $tem->set('singular', $GLOBALS['singular']); $fields = get_fields(); $db_fields = ''; $php_fields = ''; @@ -435,6 +439,7 @@ function preview() { unset($preview_tem); $preview = ereg_replace('type="submit"', 'type="submit" disabled="disabled"', $preview); tem_set('preview', $preview); + tem_show('hiddens'); set_form_action(); tem_output(); } diff --git a/metaform/main.html b/metaform/main.html index 362e6ee..d56e264 100644 --- a/metaform/main.html +++ b/metaform/main.html @@ -11,7 +11,9 @@

The form name should not contain any capitals or symbols (besides underscore)

-

Form name: (This is used as the database table name (if any) and the basename of all the files.)

+

page/table name:

+ +

Same as above but singular: (Used in messages and headers.)

Features

diff --git a/metaform/preview.html b/metaform/preview.html index 0cfd3cc..8bd5656 100644 --- a/metaform/preview.html +++ b/metaform/preview.html @@ -11,10 +11,10 @@

PREVIEW

~preview~ -

+

~hiddens~

-

+

diff --git a/metaform/template.html b/metaform/template.html index 8e6eaa7..4795d45 100644 --- a/metaform/template.html +++ b/metaform/template.html @@ -2,7 +2,7 @@ - ~form_name~ entry + ~form_name.cap~