diff options
-rw-r--r-- | css/feedback.css | 14 | ||||
-rw-r--r-- | feedback.module | 81 |
2 files changed, 64 insertions, 31 deletions
diff --git a/css/feedback.css b/css/feedback.css index 2e99793..6add9ed 100644 --- a/css/feedback.css +++ b/css/feedback.css @@ -8,3 +8,17 @@ .form-item label { margin-bottom: 5px; } +#feedback-form #edit-first-name-wrapper, +#feedback-form #edit-email-wrapper { + width: 45%; + float: left; + margin-right: 6%; +} +#feedback-form #edit-last-name-wrapper, +#feedback-form #edit-phone-wrapper { + width: 45%; + float: left; +} +#feedback-form #edit-institution { + width: 95%; +} diff --git a/feedback.module b/feedback.module index c9ab049..daae32c 100644 --- a/feedback.module +++ b/feedback.module @@ -24,22 +24,41 @@ function feedback_form($form_state) { $form = array(); - $form["name"] = array( + $form["wrapper"] = array( + '#type' => "fieldset", + "#title" => t(" + (Feedback form for the Oscad workshop conducted on + 10th May 2014 at PESIT, Bangalore.) + "), + "#prefix" => "<div class='feedback-form'>", + "#suffix" => "</div>", + ); + $form["wrapper"]["first_name"] = array( "#type" => "textfield", - "#title" => t("Full name"), - "#required" => FALSE + "#title" => t("First name"), + "#required" => TRUE + ); + $form["wrapper"]["last_name"] = array( + "#type" => "textfield", + "#title" => t("Last name"), + "#required" => TRUE ); - $form["email"] = array( + $form["wrapper"]["email"] = array( "#type" => "textfield", "#title" => t("Email"), "#required" => FALSE ); - $form["institution"] = array( + $form["wrapper"]["phone"] = array( "#type" => "textfield", - "#title" => t("Institution/College"), + "#title" => t("Phone"), "#required" => FALSE ); - $form["activities"] = array( + $form["wrapper"]["institution"] = array( + "#type" => "textfield", + "#title" => t("Institution/College"), + "#required" => TRUE + ); + $form["wrapper"]["activities"] = array( "#type" => "checkboxes", "#title" => t(" 1. Which of the following activities are you interested to @@ -48,7 +67,7 @@ "#options" => get_activities(), "#required" => TRUE ); - $form["rating"] = array( + $form["wrapper"]["rating"] = array( "#type" => "radios", "#title" => t(" 2. How would you rate this workshop on a scale of 5? @@ -56,29 +75,29 @@ "#options" => array_combine(range(1, 5), range(1, 5)), "#required" => TRUE ); - $form["liked"] = array( + $form["wrapper"]["liked"] = array( "#type" => "textarea", "#title" => t("3. Things that you liked in Oscad workshop"), "#required" => TRUE ); - $form["disliked"] = array( + $form["wrapper"]["disliked"] = array( "#type" => "textarea", "#title" => t("4. Things that you disliked in Oscad workshop"), "#required" => TRUE ); - $form["difficulties"] = array( + $form["wrapper"]["difficulties"] = array( "#type" => "textarea", "#title" => t(" 5. Did you face any difficulties while using Oscad? "), "#required" => TRUE ); - $form["missing"] = array( + $form["wrapper"]["missing"] = array( "#type" => "textarea", "#title" => t("6. Any feature you find missing in Oscad?"), "#required" => TRUE ); - $form["workshop"] = array( + $form["wrapper"]["workshop"] = array( "#type" => "radios", "#title" => t(" 7. Would you like to have a workshop @@ -89,7 +108,7 @@ ), "#required" => TRUE ); - $form["future"] = array( + $form["wrapper"]["future"] = array( "#type" => "radios", "#title" => t(" 8. Can we contact you in the future to @@ -100,7 +119,7 @@ ), "#required" => TRUE ); - $form["contact"] = array( + $form["wrapper"]["contact"] = array( "#type" => "textarea", "#title" => t(" 9. Please provide your contact details if you @@ -108,7 +127,7 @@ "), "#required" => FALSE ); - $form["magazines"] = array( + $form["wrapper"]["magazines"] = array( "#type" => "textarea", "#title" => t(" 10. In order to inform the college teachers and students @@ -117,16 +136,16 @@ "), "#required" => FALSE ); - $form["suggestion"] = array( + $form["wrapper"]["suggestion"] = array( "#type" => "textarea", "#title" => t(" 11. Any other Suggestions / Feedback / Appreciation "), "#required" => FALSE ); - $form["submit"] = array( + $form["wrapper"]["submit"] = array( "#type" => "submit", - "#value" => "Submit feedback" + "#value" => "Submit" ); return $form; } @@ -144,6 +163,9 @@ if($v["email"] && !valid_email_address($v["email"])) { form_set_error("email", "Please enter a valid email id."); } + if($v["phone"] && !is_numeric($v["phone"])) { + form_set_error("phone", "Please enter a valid phone number. (Only digits allowed)"); + } } function feedback_form_submit($form, &$form_state) { @@ -157,15 +179,16 @@ $v["activities"] = implode(",", array_filter($v["activities"])); $query = " INSERT INTO feedback ( - name, email, institution, activities, rating, liked, disliked, - difficulties, missing, workshop, future, contact, magazines, - suggestion + first_name, last_name, email, phone, institution, activities, + rating, liked, disliked, difficulties, missing, workshop, + future, contact, magazines, suggestion ) VALUES ( - '{$v["name"]}', '{$v[email]}', '{$v[institution]}', - '{$v["activities"]}', {$v["rating"]}, '{$v["liked"]}', - '{$v["disliked"]}', '{$v["difficulties"]}', '{$v["missing"]}', - {$v["workshop"]}, {$v["future"]}, '{$v["contact"]}', - '{$v["magazines"]}', '{$v["suggestion"]}' + '{$v["first_name"]}', '{$v["last_name"]}', '{$v["email"]}', + '{$v["phone"]}', '{$v["institution"]}', '{$v["activities"]}', + {$v["rating"]}, '{$v["liked"]}', '{$v["disliked"]}', + '{$v["difficulties"]}', '{$v["missing"]}', {$v["workshop"]}, + {$v["future"]}, '{$v["contact"]}', '{$v["magazines"]}', + '{$v["suggestion"]}' ) "; $result = db_query($query); @@ -175,10 +198,6 @@ function feedback_all() { $page_content = ""; $page_content .= " - Feedback form for the Oscad workshop conducted - on 10th May 2014 at PESIT, Bangalore. <br><br> - "; - $page_content .= " <div style='color: red;'> <sup>*</sup> Required </div> |