Welcome, %1$s. Please login or register.
Did you miss your activation email?



 

2637 705 - 2630 - : dragosb

eTicket CommunitySupportTips & Tricks (Moderators: jason, Hummdis)Topic: [ENHANCEMENT] Keep field values when opening a ticket upon error
: [1]   
: [ENHANCEMENT] Keep field values when opening a ticket upon error  ( 6464 )
0 and 1 Guest are viewing this topic.
Hummdis
Moderator
Super Member
*****

Karma: +13/-0
Offline Offline

: 625



« : September 30, 2011, 03:00:54 AM »

In the current version of eTicket, when a customer is filling out the 'open ticket' form, if an error occurs (mis-matched email addresses or invalid security code) the page refreshes with the error, but all of the fields are cleared except the name and email.  This patch will fix that.

1. Open the inc/open_form.php file and find the following section:

Code: (php) [Select]
if (isset($_POST['name'])) {
    $name = $_POST['name'];
}

if (isset($_POST['email'])) {
    $email = $_POST['email'];
}

$vars['name_html']          = sprintf($html['open_form']['name'], $type, $name);
$vars['email_html']         = sprintf($html['open_form']['email'], $type, $email);

if ($type == 'hidden') {
    $vars['name_html'].= $name;
    $vars['email_html'].= $email;
}

You're ging to add a long section to this...it should read:

Code: (php) [Select]
// MODIFICATION -- Display the user-entered text if the form validation fails.
// Set $_POST values, whatever they may be.
if (isset($_POST['name'])) {
    $name = $_POST['name'];
}

if (isset($_POST['email'])) {
    $email = $_POST['email'];
}

if (isset($_POST['email_confirm'])) {
    $email_confirm = $_POST['email_confirm'];
}

if (isset($_POST['phone'])) {
    $phone = $_POST['phone'];
}

if (isset($_POST['subject'])) {
    $subject = $_POST['subject'];
}

if (isset($_POST['message'])) {
    $message = $_POST['message'];
}

// Format it as HTML-safe
$name           = htmlspecialchars($name);
$email          = htmlspecialchars($email);
$email_confirm  = htmlspecialchars($email_confirm);
$phone          = htmlspecialchars($phone);
$subject        = htmlspecialchars($subject);
$message        = htmlspecialchars($message);

// Put them in the variable list.
$vars['name_html']          = sprintf($html['open_form']['name'], $type, $name);
$vars['email_html']         = sprintf($html['open_form']['email'], $type, $email);
$vars['email_confirm_html'] = sprintf($html['open_form']['email_confirm'], $type, $email_confirm);
$vars['phone_html']         = sprintf($html['open_form']['phone'], $type, $phone);
$vars['subject_html']       = sprintf($html['open_form']['subject'], $type, $subject);
$vars['message_html']       = sprintf($html['open_form']['message'], $type, $message);

// Despite doing all of this work, if the reset flag is set via $_GET, clear all values.
if (isset($_GET['reset']) && $_GET['reset'] == 'true') {
    $name           = '';
    $email          = '';
    $email_confirm  = '';
    $phone          = '';
    $subject        = '';
    $message        = '';
}
// END MODIFICATION


if ($type == 'hidden') {
    $vars['name_html'].= $name;
    $vars['email_html'].= $email;
}

If you've added any custom fields, you'll need to make sure you add them above where appropriate.

2. Save and close this file.

3. Next, open the themes/<yourtheme>/open_form.html.php file.
4. Make sure that each of the 'input' fields, including your custom fields, have the following added to the input tag:

Code: [Select]
<input .... value="<?php echo $vars['VARNAME']; ?>">
For example, the Phone field would be:

Code: [Select]
<input type="text" name="phone" id="phone" size="25" value="<?php echo $vars['phone']; ?>">
NOTE: For the 'message' variable, because this is a <textarea> tag and not an input tag, you have to place the PHP echo line in the following manner:

Code: [Select]
<textarea name="message" id="message" cols="80" rows="5"><?php echo $vars['message']; ?></textarea>
5. Once you've made all of those changes, save and close the file. You're done!

If you have questions just let me know.

Don't PM me directly for help.  Post to the forums, that's what they are for after all.  PM's to me that request help will be ignored.

Hummdis Web Design - Freelance Website Design & IT Consulting
: [1]   
eTicket CommunitySupportTips & Tricks (Moderators: jason, Hummdis)Topic: [ENHANCEMENT] Keep field values when opening a ticket upon error
: