From ba92711362bc408a37737dd4222af33fb679791b Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Tue, 24 May 2016 22:06:57 +0200 Subject: [PATCH] Cleanup. --- definitions/hotel.json | 14 +++------- prep_form.php | 28 ++++++++++++++----- templates/partials/mdl_input_country.mustache | 2 -- .../partials/mdl_input_currency.mustache | 2 -- .../partials/mdl_input_datetime.mustache | 6 ++-- templates/partials/mdl_input_decimal.mustache | 6 ++-- templates/partials/mdl_input_email.mustache | 6 ++-- templates/partials/mdl_input_number.mustache | 6 ++-- templates/partials/mdl_input_status.mustache | 2 -- templates/partials/mdl_input_tel.mustache | 6 ++-- templates/partials/mdl_input_text.mustache | 6 ++-- templates/partials/mdl_input_url.mustache | 6 ++-- 12 files changed, 39 insertions(+), 51 deletions(-) diff --git a/definitions/hotel.json b/definitions/hotel.json index 60bd839..f01e072 100644 --- a/definitions/hotel.json +++ b/definitions/hotel.json @@ -98,15 +98,15 @@ "group": 2, "short": true }, - "programMembership_memberNumber": { - "title": "Member No.", + "programMembership_program": { + "title": "Name of Program", "type": "text", "required": false, "group": 3, "short": true }, - "programMembership_program": { - "title": "Name of Program", + "programMembership_memberNumber": { + "title": "Member No.", "type": "text", "required": false, "group": 3, @@ -150,12 +150,6 @@ "required": true, "group": 0 }, - "reservationFor_image": { - "title": "Hotel Image URL", - "type": "url", - "required": false, - "group": 0 - }, "reservationFor_telephone": { "title": "Telephone", "type": "tel", diff --git a/prep_form.php b/prep_form.php index 856bc9c..2edeee0 100644 --- a/prep_form.php +++ b/prep_form.php @@ -1,12 +1,16 @@ $group) { $by_group[$group] = array( 'group_name' => $group, @@ -14,10 +18,13 @@ foreach ($field_data['groups'] as $id=>$group) { ); } +// Assign fields to groups, fill in (default) values foreach ($field_data['fields'] as $key=>$meta) { $meta['field_id'] = $key; $group_name = $field_data['groups'][$meta['group']]; $meta['group_name'] = $group_name; + + // Assign session value if set, or use default if set if (isset($_SESSION[$skey][$key])) { $meta['value'] = $_SESSION[$skey][$key]; } elseif (isset($meta['default'])) { @@ -33,17 +40,24 @@ foreach ($field_data['fields'] as $key=>$meta) { break; } } + + // Field type marker for Mustache $meta['fieldtype_' . $meta['type']] = true; + + // Add useful default values for some types if ($meta['type'] == 'datetime') { $meta['min'] = date('Y-m-d'); } - $by_group[$group_name]['fields'][$key] = $meta; + + // Add to fieldlist + $by_group[$group_name]['fields'][] = $meta; } -foreach ($by_group as $group=>$group_data) { - $by_group[$group]['fields'] = array_values($group_data['fields']); -} - -#print_r($by_group); +// Convert hash to list for Mustache compatibility $by_group = array_values($by_group); + +if ($debug) { + print_r($by_group); +} + $data['form_data'] = $by_group; diff --git a/templates/partials/mdl_input_country.mustache b/templates/partials/mdl_input_country.mustache index 64e0a91..ade9dea 100644 --- a/templates/partials/mdl_input_country.mustache +++ b/templates/partials/mdl_input_country.mustache @@ -1,8 +1,6 @@ -

-

diff --git a/templates/partials/mdl_input_currency.mustache b/templates/partials/mdl_input_currency.mustache index 6217bf9..7eda752 100644 --- a/templates/partials/mdl_input_currency.mustache +++ b/templates/partials/mdl_input_currency.mustache @@ -1,7 +1,5 @@ -

-

diff --git a/templates/partials/mdl_input_datetime.mustache b/templates/partials/mdl_input_datetime.mustache index a801965..b8df7bb 100644 --- a/templates/partials/mdl_input_datetime.mustache +++ b/templates/partials/mdl_input_datetime.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a valid date! -
-

+
diff --git a/templates/partials/mdl_input_decimal.mustache b/templates/partials/mdl_input_decimal.mustache index c29ecc7..5e106b5 100644 --- a/templates/partials/mdl_input_decimal.mustache +++ b/templates/partials/mdl_input_decimal.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a value! -
-

+
diff --git a/templates/partials/mdl_input_email.mustache b/templates/partials/mdl_input_email.mustache index 3afa84e..e258857 100644 --- a/templates/partials/mdl_input_email.mustache +++ b/templates/partials/mdl_input_email.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a valid email address! -
-

+
diff --git a/templates/partials/mdl_input_number.mustache b/templates/partials/mdl_input_number.mustache index 1b77723..f3a8b35 100644 --- a/templates/partials/mdl_input_number.mustache +++ b/templates/partials/mdl_input_number.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a value! -
-

+
diff --git a/templates/partials/mdl_input_status.mustache b/templates/partials/mdl_input_status.mustache index b5683a3..b571b07 100644 --- a/templates/partials/mdl_input_status.mustache +++ b/templates/partials/mdl_input_status.mustache @@ -1,4 +1,3 @@ -

Select your status: -

diff --git a/templates/partials/mdl_input_tel.mustache b/templates/partials/mdl_input_tel.mustache index 10f8ee9..f2c227b 100644 --- a/templates/partials/mdl_input_tel.mustache +++ b/templates/partials/mdl_input_tel.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a valid phone number! -
-

+
diff --git a/templates/partials/mdl_input_text.mustache b/templates/partials/mdl_input_text.mustache index 379a270..59b56c6 100644 --- a/templates/partials/mdl_input_text.mustache +++ b/templates/partials/mdl_input_text.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a value! -
-

+
diff --git a/templates/partials/mdl_input_url.mustache b/templates/partials/mdl_input_url.mustache index 1f8734e..b471f4c 100644 --- a/templates/partials/mdl_input_url.mustache +++ b/templates/partials/mdl_input_url.mustache @@ -1,7 +1,5 @@ -

-

+
Please input a valid URL! -
-

+